bs-rx
bs-rx copied to clipboard
Support for subjects
Does the library have any support for subjects? If not, any pointers on how to add that in?
Thanks!
Just fyi, I did something like the following and it seems to work:
[@bs.module "rxjs"] [@bs.new]
external makeSubject: unit => subject('a) = "Subject";
module Subject = {
[@bs.send] external next: (subject('a), 'a) => unit = "next";
[@bs.send] external error: (subject('a), 'e) => unit = "error";
[@bs.send] external complete: subject('a) => unit = "complete";
external observer: subject('a) => Rx.observer('a) = "%identity";
external observable: subject('a) => Rx.observable('a) = "%identity";
};
Thank you @hanrelan for your inputs. The library does not currently support Subject. What you are attempting will work. I had imagined something similar. Subject would essentially be a tuple of (observer, observable)
. Functions like next
, error
and complete
would be available on observer
and observable
would be ordinary observable.