The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/providers/createObservableFromReactiv...

19 lines
395 B

import { Tracker } from 'meteor/tracker';
export const createObservableFromReactive = (fn) => (...fnArgs) => {
const args = fnArgs.slice(0, -1);
const listener = fnArgs.pop();
if (!listener) {
return Tracker.nonreactive(() => fn(...args));
}
const computation = Tracker.autorun(() => {
const value = fn(...args);
listener(value);
});
return () => {
computation.stop();
};
};