How to use the rx-lite.Rx.Observable function in rx-lite

To help you get started, we’ve selected a few rx-lite 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 jahan-addison / gridpaste / application / src / subscriptions / board.js View on Github external
warned++;
    if (!App.isRecording && warned == 4) {
      alert('Warning: Your actions are not being recorded! Press "Start Record" or the tab key to begin recording');
    }
    var target = $(e.target);
    if (!$('.slider').length) {
      slider(target.next().html(), 230, 'auto', '#application', target.parent().parent());
    }
  });

  /**
    Board operations
   */

  var $operationSources      = '.button.draw, .button.transform, .button.misc';
  var $operationSource       = Rx.Observable.fromEventPattern(
    function addHandler(h) { $('#application').on('click', $operationSources, h) },
    function delHandler(h) { $('#application').off('click', $operationSources, h) }
  );

  var $operationSubscription = $operationSource.subscribe(function(e) {
    var target    = $(e.target).parent().attr('class').split('-');
    var targetOperation = target[0],
        targetCommand   = target[1];
    // validation error
    if ($(e.target).parent().find('[data-error]').length) {
      alert($(e.target).parent().find('[data-error]').first().attr('data-error'));
      return;
    }
    // the request
    var $command  = {
      'targetOperation': targetOperation,
github jahan-addison / gridpaste / application / src / subscriptions / function.js View on Github external
module.exports = function(App) {
  var $sources = $('.function'),
      $source  = Rx.Observable.fromEvent($sources, "keypress");
  // Filter when the application is 'off'
  $source      = $source.filter(function() {
    return !$('#application').hasClass('off');
  });
  var $functionSubscription = $source.subscribe(function(e) {
    if (e.keyCode == 13) {
      var func = new Parser(e.target.value);
      try {
        func.run(); // generate parse tree
      } catch(e) {
        // syntax error
        alert("Syntax: " + e.message);
        return false;
      }
      var targetOperation = 'func',
          targetCommand   = func.identifier || 'plot';
github jahan-addison / gridpaste / application / src / subscriptions / zoom.js View on Github external
module.exports = function(App, board) {
  var $zoomSources      = $('.zoom.in, .zoom.out');
  var $zoomSource       = Rx.Observable.fromEvent($zoomSources, "click");

  // Filter when the application is 'off'
  $zoomSource = $zoomSource.filter(function() {
    return !$('#application').hasClass('off');
  });

  var $zoomSubscription = $zoomSource.subscribe(function(e) {
    var target          = $(e.target),
        targetCommand = target.hasClass('in') ? 'zoomIn' : 'zoomOut';
    if ((targetCommand == 'zoomIn'  && board.zoomX < 5.9) ||
        (targetCommand == 'zoomOut' && board.zoomX > 0.167)) {
      var $command  = {
        'targetOperation': 'zoom',
        'targetCommand':   targetCommand,
        'command':         command['zoom'][targetCommand]
      };
github jahan-addison / gridpaste / application / src / subscriptions / board.js View on Github external
module.exports = function(App) {
  /**
    Pre-queries
   */
  var $querySources  = $([
    '.circle',   '  .angle',   '.arc',
    '.ellipse',    '.segment', '.line',
     '.polygon',   '.point',   '.text',
     '.rotate',    '.reflect', '.shear',
     '.translate', '.scale',   '.delete_'
  ].join(','));
  // The query observer prepares the way for the following operations subscription
  var $querySource       = Rx.Observable.fromEvent($querySources, 'click');
  // Filter queries when the application is 'off'
  $querySource           = $querySource.filter(function() {
    return !$('#application').hasClass('off');
  });
  var warned = 0;
  var $querySubscription = $querySource.subscribe(function(e) {
    // before we do anything, warn if not recording after 4 queries
    warned++;
    if (!App.isRecording && warned == 4) {
      alert('Warning: Your actions are not being recorded! Press "Start Record" or the tab key to begin recording');
    }
    var target = $(e.target);
    if (!$('.slider').length) {
      slider(target.next().html(), 230, 'auto', '#application', target.parent().parent());
    }
  });

rx-lite

Lightweight library for composing asynchronous and event-based operations in JavaScript

Unrecognized
Latest version published 9 years ago

Package Health Score

69 / 100
Full package analysis