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

tbg-flux-factory

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tbg-flux-factory

Factory for flux

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

tbg-flux-factory

Factory wrapper for flux

Install

npm install tbg-flux-factory --save

https://www.npmjs.com/package/tbg-flux-factory

How it works

Working example gist

Register a new store with actions
var FluxFactory = require('tbg-flux-factory');

var LoginStore = FluxFactory.createStore({
  name		: 'Login',
  data		: {
    logged_in			: false,
    login_open    : false
  },
	actions : {
	  view    : {
	    toggle_showLogin: function () {
	      LoginStore.setState({
	        login_open  : !LoginStore.getStateValue('login_open')
	      });
	    }
	  },
	  server	: {
    	login: function (params) {
        xhr('to_login_', params);
    	}
    }
	}
});
Register actions to a store
var Flux        = require('tbg-flux-factory');
var LoginStore  = Flux.getStore('Login');

LoginStore.registerActions({
  view    : {
    toggle_showLogin: function () {
      LoginStore.setState({
        login_open  : !LoginStore.getStateValue('login_open')
      });
    }
  },
  server	: {
  	login: function (params) {
      xhr('to_login_', params);
  	}
  }
});

Use with a synced state to components
var Flux        = require('tbg-flux-factory');
var LoginStore  = Flux.getStore('Login');

---
getInitialState : function () {
	return LoginStore.getState();
},

componentWillMount : function () {
  var that = this;
  LoginStore.addChangeListener(function () {
  	that.setState(LoginStore.getState());
  });
},

---
Listen to other stores
var Flux        = require('tbg-flux-factory');
var LoginStore  = Flux.getStore('Login');
var UserStore  	= Flux.getStore('User');

LoginStore.addChangeListener(function () {
	UserStore.Actions.fetchUserDetails()
});

FAQs

Package last updated on 29 Jul 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

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