New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rxpression

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxpression

A simple Reactive Extension combinator using JavaScript-based expression

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

Rxpression

Build Status

A simple Reactive Extension combinator using JavaScript-based expression

Abstract

Rxpression is a Reactive Extension Observable generator using simple JavaScript expression. The Rxpression instance accepts context information defining variables used in the expression, yields an Observable stream which emits evaluated result.

If a variable in the context or any intermediate evaluated result is Promise or Observable, the evaluation is applied to its emitted result.

It enables you to describe dependencies simply, instead of writing Promise chaining or Observable methods, even in asynchronous streaming environment.

Install

$ npm install rxpression

Usage

Simple Calculation

var rxpr = new Rxpression('a * b - 1');
var context = {
  a: new Rx.Observable.interval(1000).map(function(i) { return i+1; }),
  b: 2
};
rxpr.evaluate(context).subscribe(function(result) {
  console.log(result); // 1, 3, 5, 7, ...
});

Ajax with jQuery

$('body').html(
  '<select id="state">'+
    '<option>CA</option>'+
    '<option>TX</option>'+
    '<option>OR</option>'+
  '</select>'
);
var stateSelect = $('#state');
var context = {
  listAllCounty: function(state) {
    var url = 'http://api.sba.gov/geodata/county_links_for_state_of/' + state + '.json';
    return $.getJSON(url).promise();
  },
  state: Rx.Observable.fromEvent(stateSelect, 'change')
};

// get count of counties in the selected state in United States
var rxpr = new Rxpression('listAllCounty(state.target.value).length');
rxpr.evaluate(context).subscribe(function(result) {
  console.log('state conties: ', result);
});

FAQs

Package last updated on 18 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts