0

I have a stream daysFromApi$ with data (days with meals) from API. When a 'delete' button is clicked, I push mealId to this.deleteBus$. I want to have a new value in the stream: daysAfterDelete$. My problem is that 'first' event is always triggered, but 'done' never triggers, flatMapLatest does not work, map neither.

const daysAfterDelete$ = this.deleteBus$
        .log('first') // triggers when new mealId is pushed to deleteBus(a button is clicked)
        .flatMapLatest(mealId => Bacon.combineAsArray(daysFromApi$, mealId))
        .log('done'); // never triggers

I want to get following flow:

daysFromApi$    :      A          B                             C
deleteBus$      :         1             2               3
daysAfterDelete$:         (1,A)        (2,B)           (3,B)
Jan Grz
  • 1,373
  • 14
  • 18

1 Answers1

1

Not quite sure what you want to achieve, but if you want to get the latest value of "days" when the delete is clicked, you can use sampledBy. https://www.webpackbin.com/bins/-Ki3lTzM8PM4zeJKK9C0

raimohanska
  • 3,265
  • 17
  • 28
  • Thank you! it worked! This is what I was looking for. I am new to reactive programming, and I am lacking the proper vocabulary, that is why my question may seem so confusing. – Jan Grz Apr 19 '17 at 21:26