You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by AlexandrHoroshih June 4, 2021
At the moment there is no option in basic effector api to do something like call that event on every item from this array in store or in event payload
Idea is to create operator which is something like this:
sampleForEach({source: Store<T[]>|Event<T[]>,
clock,target: Event<T>|Effect<T>// will be run for Every T from T[] in source})
construnTransaction=createEvent<Transaction>()construnTransactionGroup=createEvent<Transaction[]>()sampleForEach({source: runTransactionGroup,target: runTransaction,// run all transactions from group one-by-one})runTransaction.watch(t=>console.log('Handling transaction...',t))// for example, we just logging all transactionsrunTransaction({type: 'transactionType',body: 'Single',})runTransactionGroup([{type: 'transactionType',body: 'group1',},{type: 'transactionType',body: 'group2',},{type: 'transactionType',body: 'group3',},])// in logs:Handlingtransaction...
{type: "transactionType",body: "Single"}Handlingtransaction...
{type: "transactionType",body: "group1"}Handlingtransaction...
{type: "transactionType",body: "group2"}Handlingtransaction...
{type: "transactionType",body: "group3"}```</div>
The text was updated successfully, but these errors were encountered:
Discussed in #147
Originally posted by AlexandrHoroshih June 4, 2021
At the moment there is no option in basic effector api to do something like
call that event on every item from this array in store or in event payload
Idea is to create operator which is something like this:
Live example:
https://share.effector.dev/vx6hm1il
Possible use case:
The text was updated successfully, but these errors were encountered: