Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise.fromEvent takes all of the signal's parameters #186

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tacheometry
Copy link

@tacheometry tacheometry commented Oct 24, 2022

Promise.fromEvent's predicate only took the first parameter from the RBXScriptSignal. Now it should take all of them. Before:

import { MarketplaceService } from "@rbxts/services";

Promise.fromEvent(MarketplaceService.PromptGamePassPurchaseFinished, (player, gamePassId, wasPurchased) => {
	// gamePassId and wasPurchased are not passed
	return true;
})

Now, gamePassId and wasPurchased should be passed.

Promise.fromEvent's predicate only took the first parameter from the RBXScriptSignal. Now it should take all of them.
Before:
https://roblox-ts.com/playground/#code/JYWwDg9gTgLgBAbzgWQIZQNYFMZgDaoDGWAyllAG7DFwC+cAZlBCHAEQACUARgB4wBnAPQDyVYgLYBuAFAyACsxDBRAOiYsAohSwA7GAAo0mHPiKkx1LKsUswMAOKoQWeagED5AVyiEAFu5YAGLAuip+WAAmADRwBmYAnuSxAObOru4CAJIxcADu7t6+AaKRAJRwALwAfIgyAJBCQnBpLm4eOXCoupH5hT7+gb3oWHC6EPBgmVENUDg+unAwUF5YsrRlMkA

```ts
import { MarketplaceService } from "@rbxts/services";

Promise.fromEvent(MarketplaceService.PromptGamePassPurchaseFinished, (player, gamePassId, wasPurchased) => {
	// gamePassId and wasPurchased are not passed
	return true;
})
```

Now, `gamePassId` and `wasPurchased` should be passed.
@tacheometry
Copy link
Author

Found a bit of an issue, when attaching a then callback, the types are incorrect:

import { MarketplaceService } from "@rbxts/services";

Promise.fromEvent(MarketplaceService.PromptGamePassPurchaseFinished, (player, gamePassId, wasPurchased) => {
	return true;
}).then((a) => {
	// "a" is typed as [player: Player, passId: number, purchased: boolean]
	print(a); // Player1
	print(typeOf(a)); // Instance
	// the return value is not actually an array. Maybe it should be a LuaTuple?
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant