How to use the rx.CompositeDisposable function in rx

To help you get started, we’ve selected a few rx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pH200 / cycle-react / src / stream.js View on Github external
function replicateAllInteraction$(input, proxy) {
  let subscriptions = new Rx.CompositeDisposable();
  let selectors = proxy._interaction$;
  for (let selector in selectors) { if (selectors.hasOwnProperty(selector)) {
    let elemEvents = selectors[selector];
    for (let eventName in elemEvents) { if (elemEvents.hasOwnProperty(eventName)) {
      let event$ = input.choose(selector, eventName);
      if (event$ !== null) {
        let subscription = replicate(event$, elemEvents[eventName]);
        subscriptions.add(subscription);
      }
    }}
  }}
  return subscriptions;
}
github cyclejs / cyclejs / rx-run / src / web / custom-element-widget.js View on Github external
function subscribeDispatchers(element) {
  let {customEvents} = element.cycleCustomElementMetadata;
  let disposables = new Rx.CompositeDisposable();
  for (let name in customEvents) { if (customEvents.hasOwnProperty(name)) {
    if (typeof customEvents[name].subscribe === 'function') {
      let disposable = customEvents[name].subscribe(
        makeDispatchFunction(element, name)
      );
      disposables.add(disposable);
    }
  }}
  return disposables;
}
github TryStarboard / Starboard / source / client / higher-order-components / observeStore.js View on Github external
subscribeToStoreKeypath(props) {
        this.disposeStoreKeypathSubscription();
        const keypathMap = getKeypath(props);
        for (const [key, keypath] of entries(keypathMap)) {
          this.observableMap[key] = oop.observe(keypath);
        }
        if (transform) {
          this.observableMap = transform(this.observableMap);
        }
        this.disposableBag = new CompositeDisposable();
        Object.keys(this.observableMap).forEach((key) => {
          const disposable = this.observableMap[key].subscribe((val) => this.setState({[key]: val}));
          this.disposableBag.add(disposable);
        });
      }
github trxcllnt / rxjs-extras / index.js View on Github external
return Rx.Observable.createWithDisposable(function(observer) {
			
			var key = keySelector();
			var cache = cacheSelector();
			
			if(cache.hasOwnProperty(key) === false) cache[key] = source.replay().refCount();
			
			var subscriptions = new Rx.CompositeDisposable();
			
			var cacheObservable = Rx.Observable.switchCase(keySelector, cache);
			var durationObservable = durationSelector(key);
			
			var durationSubscription = durationObservable.take(1).subscribe(function(){}, null, function(){
				delete cache[key];
			});
			
			var switchSubscription = cacheObservable.subscribe(observer);
			
			subscriptions.add(durationSubscription);
			subscriptions.add(switchSubscription);
			
			return subscriptions;
		});
	});
github tierratelematics / prettygoat / scripts / streams / MergeSort.ts View on Github external
return Observable.create(observer => {
        let buffers: Event[][] = _.map(observables, o => []);
        let completed:boolean[] = _.map(observables, o => false);
        let disposable = new CompositeDisposable();

        _.forEach(observables, (observable, i) => {
            disposable.add(observable.subscribe(event => {
                buffers[i].push(event);
                if (observablesHaveEmitted(buffers, completed)) {
                    let item = getLowestItem(buffers);
                    if (item) observer.onNext(item);
                }
            }, error => {
                observer.onError(error);
            }, () => {
                completed[i] = true;
                if (_.every(completed, completion => completion)) {
                    let flushed = false;
                    while (!flushed) {
                        let item = getLowestItem(buffers);
github huluoyang / freecodecamp.cn / common / app / routes / Jobs / components / JobTotal.jsx View on Github external
constructor(...args) {
    super(...args);
    this._subscriptions = new CompositeDisposable();
  }
github bberak / react-native-game-engine / src / DefaultTouchProcessor.js View on Github external
let longTouch = touchStart.flatMap(e =>
			Rx.Observable
				.return(e)
				.delay(triggerLongPressEventAfter)
				.takeUntil(
					touchMove
						.merge(touchEnd)
						.first(x => x.identifier === e.identifier)
				)
		);

		let touchStartComposite = new Rx.CompositeDisposable();
		let touchMoveComposite = new Rx.CompositeDisposable();
		let touchEndComposite = new Rx.CompositeDisposable();
		let touchPressComposite = new Rx.CompositeDisposable();
		let longTouchComposite = new Rx.CompositeDisposable();

		touchStartComposite.add(
			touchStart
				.groupBy(e => e.identifier)
				.map(group => {
					return group.map(e => {
						touches.push({
							id: group.key,
							type: "start",
							event: e
						});
					});
				})
				.subscribe(group => {
					touchStartComposite.add(group.subscribe());
github shiftyp / redurx / lib / state / node.js View on Github external
const connect = () => {
    const allDisposable = new Rx.CompositeDisposable();
    const children = getChildrenSubject && getChildrenSubject.getValue();
    if (children) {
      const keys = Object.keys(children);
      keys.forEach(key => allDisposable.add(
        children[key].getValue().connect()
      ));
    }
    allDisposable.add(
      asObservable().connect()
    );
    return allDisposable;
  };