Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fluir

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluir - npm Package Compare versions

Comparing version 0.2.0 to 0.2.3

.travis.yml

103

index.js
var
_ = require('underscore'),
Promise = require('es6-promise').Promise,
EventEmitter = require('eventemitter2').EventEmitter2,
Router = require('director').Router,
CHANGE_EVENT = 'change';
Scope = require('./lib/scope').Scope,
RouteHandler = require('./lib/routeHandler').RouteHandler,
DispatchHandler = require('./lib/dispatchHandler').DispatchHandler;
/**
* Scope
*/
function Scope(map){
if (map) {
this._values = map;
}
}
Scope.prototype.push = function(values){
var scope = new Scope(values || {});
scope._parent = this;
return scope;
};
Scope.prototype.get = function(key){
var target = this;
var result = target._values[key];
while (result === undefined && target) {
target = target._parent;
result = target ? target._values[key] : result;
}
if (target) {
return result;
} else {
throw key + " not found";
}
};
/**
* RouteHandler
*/
function RouteHandler(routeDelegates){
this._router = new Router();
var actions = {};
var self = this;
_.each(routeDelegates, function(routeDelegate){
_.chain(routeDelegate)
.functions()
.filter(function(x){
return x.charAt(0) === '/';
})
.each(function(route){
var action = function(){
var args = Array.prototype.slice.call(arguments);
routeDelegate[route].apply(routeDelegate, args);
self.emitChange();
};
actions[route] = action;
self._router.on(route, action);
});
_.chain(routeDelegate)
.keys()
.filter(function(x){
return x.charAt(0) === '/' && typeof(routeDelegate[x]) === 'string';
})
.each(function(route){
var actionName = routeDelegate[route];
self._router.on(route, actions[actionName]);
});
});
}
RouteHandler.prototype.initRoute = function(route){
this._router.init(route);
};
RouteHandler.prototype.go = function(url){
this._router.setRoute(url);
};
/**
* DispatchHandler
*/
function DispatchHandler(listeners){
this._listeners = listeners;
}
DispatchHandler.prototype.dispatch = function(event_name, payload){
var self = this;
var promises = _.map(this._listeners, function(store){
var fn = store[event_name];
if (typeof(fn) === 'function') {
return fn.call(store, payload);
}
});
return Promise.all(promises);
};
DispatchHandler.prototype.emitChange = function(){
this.emit(CHANGE_EVENT);
};
/**
* Application

@@ -118,3 +29,3 @@ */

this.emitChange = _.bind(function(){
return DispatchHandler.prototype.emitChange.call(this);
return Application.prototype.emitChange.call(this);
}, this);

@@ -125,3 +36,3 @@

//when a store fires a change event, we forward to the root view listening
store.on(CHANGE_EVENT, function(){
store.on('change', function(){
self.emitChange(store);

@@ -142,2 +53,6 @@ });

Application.prototype.emitChange = function(){
this.emit('change');
};
/**

@@ -144,0 +59,0 @@ * ViewMixin

{
"name": "fluir",
"version": "0.2.0",
"version": "0.2.3",
"description": "Dispatcher, router, store helper for React apps.",

@@ -34,9 +34,10 @@ "main": "index.js",

"devDependencies": {
"fs-plus": "^2.2.4",
"istanbul": "^0.3.0",
"fs-plus": "^2.3.0",
"istanbul": "^0.3.2",
"nodeunit": "^0.9.0",
"z5h.nodeunit-asserts": "^0.0.4",
"react": "^0.11.1",
"react-tools": "^0.11.1",
"watchify": "^1.0.1",
"browserify": "^5.9.1"
"watchify": "^1.0.2",
"browserify": "^5.11.1"
},

@@ -43,0 +44,0 @@ "dependencies": {

fluir
=========
[![Build Status](https://travis-ci.org/z5h/fluir.svg?branch=master)](https://travis-ci.org/z5h/fluir)
Dispatcher, router, store helper for React apps.

@@ -10,2 +13,2 @@

Or just look at the implementation. It's only [one file](https://github.com/z5h/fluir/blob/master/index.js).
Or just look at [the implementation](https://github.com/z5h/fluir/blob/master/index.js).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc