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

✨Beef up the call() function to promises and async fns #803

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

cowboyd
Copy link
Member

@cowboyd cowboyd commented Oct 27, 2023

Motivation

resolve #798

Approach

This adds the following variations

// promise
call(Promise.resolve("hello"));
call(async () => "hello");

// Operation
call({ *[Symbol.iterator]() { return "hello" } } );
call(function*() { return "hello" });

However, it does not add the variation for constant values because they could include arrays and strings which are themselves iterable and so difficult to tell if they are an Operation or not.

@cowboyd cowboyd requested a review from neurosnap October 27, 2023 22:57
@cowboyd cowboyd force-pushed the beef-up-call branch 5 times, most recently from a4e8651 to a08b9c0 Compare October 28, 2023 19:27
Right now there are a lot of different ways to convert values into
operations. There is `expect()` (Promise->Operation),
`call()(Operation->Operation)`, and `op` (Function -> Operation>.

starfx [unifies all of these concepts into a single
operation](https://github.com/neurosnap/starfx/blob/main/fx/call.ts)

We should bring this into Effection core.

This adds the following variations

```ts
// promise
call(Promise.resolve("hello"));
call(async () => "hello");

// Operation
call({ *[Symbol.iterator]() { return "hello" } } );
call(function*() { return "hello" });
```
@cowboyd cowboyd merged commit 307026e into v3 Nov 2, 2023
1 check passed
@cowboyd cowboyd deleted the beef-up-call branch November 2, 2023 20:28
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.

Beefed up call() function.
2 participants