How to use the rx.Subject 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 CharlieHess / slack-poker-bot / tests / player-interaction-spec.js View on Github external
beforeEach(function() {
      messages = new rx.Subject();
      channel = { 
        send: function() { 
          // NB: Posting a message to the channel returns an editable message
          // object, which we're faking out here.
          return { updateMessage: function() { } };
        } 
      };
      scheduler = new rx.HistoricalScheduler();
      players = [];
    });
github pH200 / cycle-react / src / dom-user.js View on Github external
_defineRootElemStream() {
    // Create rootElem stream and automatic className correction
    let originalClasses = (this._domContainer.className || '').trim().split(/\s+/);
    //console.log('%coriginalClasses: ' + originalClasses, 'color: lightgray');
    this._rawRootElem$ = new Rx.Subject();
    this._rootElem$ = this._rawRootElem$
      .map(function fixRootElemClassName(rootElem) {
        let previousClasses = rootElem.className.trim().split(/\s+/);
        let missingClasses = originalClasses.filter(function (clss) {
          return previousClasses.indexOf(clss) < 0;
        });
        //console.log('%cfixRootElemClassName(), missingClasses: ' + missingClasses,
        //  'color: lightgray');
        rootElem.className = previousClasses.concat(missingClasses).join(' ');
        //console.log('%c  result: ' + rootElem.className, 'color: lightgray');
        //console.log('%cEmit rootElem$ ' + rootElem.tagName + '.' + rootElem.className,
        //  'color: #009988');
        return rootElem;
      })
      .shareReplay(1);
  }
github laszlokorte / tams-tools / app / components / kv / index.js View on Github external
export default ({
  DOM, // DOM driver source
  globalEvents, // globalEvent driver sources
}) => {
  const openData$ = new Subject();
  const importExpression$ = new Subject();
  const viewSetting$ = new Subject();

  const actions = intent({
    DOM, globalEvents,
    openData$,
    importExpression$,
    viewSetting$: viewSetting$,
  });

  const state$ = model(O.empty(), actions);

  const plaData$ = state$.map(({state}) =>
    toPLA(state.diagram, state.currentKvMode, state.currentLoop.cube)
  ).share();

  const jsonData$ = state$.map(({state}) =>
github panacloud / learn-angular / step9_gulp_router / node_modules / angular2 / src / facade / async.js View on Github external
function EventEmitter() {
        _super.call(this);
        // System creates a different object for import * than Typescript es5 emit.
        if (Rx.hasOwnProperty('default')) {
            this._subject = new Rx.default.Rx.Subject();
            this._immediateScheduler = Rx.default.Rx.Scheduler.immediate;
        }
        else {
            this._subject = new Rx.Subject();
            this._immediateScheduler = Rx.Scheduler.immediate;
        }
    }
    EventEmitter.prototype.observer = function (generator) {
github tierratelematics / prettygoat / test / api / ProjectionsManagerControllerSpec.ts View on Github external
() => {
            holder = {};
            subjectProjectionStatus = new Subject();
            notifications = [];
            projectionRunner = TypeMoq.Mock.ofType(MockProjectionRunner);
            holder["nameProjection"] = projectionRunner.object;
            request = TypeMoq.Mock.ofType(MockRequest);
            response = TypeMoq.Mock.ofType(MockResponse);
            response.setup(s => s.status(TypeMoq.It.isAny())).returns(a => response.object);
            subject = new ProjectionsManagerController(holder, subjectProjectionStatus);

            subjectProjectionStatus.subscribe((t: string) => {
                notifications.push(t);
            });
        }
    );
github marinels / webrx-react / src / WebRx / Command.ts View on Github external
constructor(
    protected executeAction: (parameter: any) => Observable,
    canExecute?: Observable,
  ) {
    this.isExecutingSubject = new BehaviorSubject(false);
    this.canExecuteSubject = new BehaviorSubject(canExecute == null);
    this.resultsSubject = new Subject();
    this.thrownErrorsSubject = new Subject();

    this.canExecuteSubscription = (canExecute || asObservable(true))
      .combineLatest(this.isExecutingSubject, (ce, ie) => ce === true && ie === false)
      .catch(e => {
        handleError(e, this.thrownErrorsSubject);

        return asObservable(false);
      })
      .distinctUntilChanged()
      .subscribe(this.canExecuteSubject);
  }
github tomlarkworthy / animaxe / compiled / src / animaxe.js View on Github external
return Rx.Observable.create(function (observer) {
                var first = new Rx.Subject();
                var second = new Rx.Subject();
                var firstTurn = true;
                var current = first;
                if (exports.DEBUG_THEN)
                    console.log("then: attach");
                var secondAttach = null;
                var firstAttach = self.attach(first.subscribeOn(Rx.Scheduler.immediate)).subscribeOn(Rx.Scheduler.immediate).subscribe(function (next) {
                    if (exports.DEBUG_THEN)
                        console.log("then: first to downstream");
                    observer.onNext(next);
                }, observer.onError.bind(observer), function () {
                    if (exports.DEBUG_THEN)
                        console.log("then: first complete");
                    firstTurn = false;
                    secondAttach = follower.attach(second.subscribeOn(Rx.Scheduler.immediate)).subscribeOn(Rx.Scheduler.immediate).subscribe(function (next) {
                        if (exports.DEBUG_THEN)
github fdecampredon / rx-react / lib / createClass.js View on Github external
function initComponent(comp, spec) {
  comp.__lifecycle = {
    componentWillMount: new Rx.Subject(),
    componentDidMount: new Rx.Subject(),
    componentWillReceiveProps: new Rx.Subject(),
    componentWillUpdate: new Rx.Subject(),
    componentDidUpdate: new Rx.Subject(),
    componentWillUnmount: new Rx.Subject(),
  };

  var state;
  if (spec.getInitialState) {
    state = spec.getInitialState(comp.props);
  }
  if (spec.getStateStream) {
    var stateStream = spec.getStateStream();
    var initializing = true;
    comp.__stateSubscription = stateStream.subscribe(function (val) {
      if (!state) {
        state = val;
      }
github codesuki / reactive-flux / src / action.js View on Github external
var Action = function (fn) {
	var begin = new Rx.Subject();
	var end = new Rx.Subject();

	var action = function (data) {
		if (fn) {
			action.onNext(fn.apply(null, arguments));
		} else {
			action.onNext(data);
		}
	};

	for (var key in Rx.Subject.prototype) {
		action[key] = Rx.Subject.prototype[key];
	}

	Rx.Subject.call(action);

	action._onNext = action.onNext;
github fdecampredon / react-rxjs-todomvc / src / actions / TodoActions.js View on Github external
/*jshint node : true */

var Rx      = require('rx'),
    assign  = require('../utils/assign'),
    uuid    = require('../utils/uuid');

/**
 * A set of actions that will be exposed into views
 * Thoses actions will trigger model update
 */
var TodoActions = {
  create: new Rx.Subject(),
  updateTitle: new Rx.Subject(),
  toggle: new Rx.Subject(),
  toggleAll: new Rx.Subject(),
  destroy: new Rx.Subject(),
  clearCompleted: new Rx.Subject(),
};

/**
 * Register our actions against an updates stream
 * each one of our actions will push operation to apply on the model
 * into the stream.
 */
TodoActions.register = function (updates) {
    this.create
        .map(function (title) {
            return function (todos) {
                return todos.concat({
                    id: uuid(),
                    title: title,