Fork me on GitHub
#missionary
<
2021-08-07
>
ribelo11:08:17

Does missionary have something similar in functionality to rxjs/subject and its .next? https://rxjs.dev/guide/subject

ribelo11:08:51

import { BehaviorSubject } from 'rxjs';
const subject = new BehaviorSubject(0); // 0 is the initial value

subject.subscribe({
  next: (v) => console.log(`observerA: ${v}`)
});

subject.next(1);
subject.next(2);

subject.subscribe({
  next: (v) => console.log(`observerB: ${v}`)
});

subject.next(3);

// Logs
// observerA: 0
// observerA: 1
// observerA: 2
// observerB: 2
// observerA: 3
// observerB: 3

leonoel13:08:11

multicast is provided by signal! and stream!. The API is slightly different, here is an example for continuous values :

(let [!a (atom 0)]
  [(fn [x] (reset! !a x))
   (m/signal! (m/watch !a))])