I'm new to RxJS. In my app I need independent cancellation of deferred action. Here's a working example (the delay is 3 seconds). But when I choose to delete multiple items and cancel one of them, then canceled all at once.
Epic code:
const itemsEpic = action$ =>
action$.ofType('WILL_DELETE')
.flatMap(action =>
Observable.of({type: 'DELETE', id: action.id})
.delay(3000)
.takeUntil(action$.ofType('UNDO_DELETE'))
)
I think I need to pass an id
to takeUntil
operator, but I don't know how to do it.
If I understand the
takeUntil
operator correctly, it stops emitting new items from theObservable
it was called on, once the argumentObservable
emits it's first item. With this in mind you could do something like this: