awai
awai copied to clipboard
Promised state management library with a unique events system, where every event is thennable, which allows to write logic in a saga-like way using async functions
- [ ] DevHunt - [x] HN - [x] LinkedIn blog post - [ ] StackOverflow article - [x] Dev.to post - [x] GitHub Discussions
Update config of AsyncState and AsyncSelector with `{ lazy?: boolean }` config prop, so that their initializing predicate is not run until state is read.
Right now asyncSelector is used if either any of dependencies is async readable, or if predicate's constructor is `AsyncFunction`. ```ts const isAsyncPredicate = predicate.constructor.name === 'AsyncFunction'; ``` [Source](https://github.com/yuriyyakym/awai/blob/master/src/selector/selector.ts#L13) ### Current...
Right now the only way to trigger a scenario with multiple AwaiEvents's/promises is to have a trigger callback and use Promise.race, like so: ```ts scenario( () => Promise.race([ action1.events.invoked, delay(1000),...
It may handle `action` and readable states. Current approach: ```ts const items = state(); const createItem = action(); scenario(items.events.changed, () => { /* ... */ }); scenario(createItem.events.invoked, () => {...