codesuki / Reactive Flux
Licence: mit
Fluxish model implemented with RxJS
Stars: ✭ 71
Programming Languages
javascript
184084 projects - #8 most used programming language
js
455 projects
Projects that are alternatives of or similar to Reactive Flux
Awesome Reactive Programming
A repository for sharing all the resources available on Reactive Programming and Reactive Systems
Stars: ✭ 163 (+129.58%)
Mutual labels: rxjs, reactive-extensions
Rx Connect
Glue your state and pure React components with RxJS
Stars: ✭ 86 (+21.13%)
Mutual labels: rxjs, flux
Fluorine
[UNMAINTAINED] Reactive state and side effect management for React using a single stream of actions
Stars: ✭ 287 (+304.23%)
Mutual labels: rxjs, flux
Reactor Core
Non-Blocking Reactive Foundation for the JVM
Stars: ✭ 3,891 (+5380.28%)
Mutual labels: reactive-extensions, flux
Awesome Rxjs
A collection of awesome RxJS resources
Stars: ✭ 314 (+342.25%)
Mutual labels: rxjs, reactive-extensions
Tanok
Elm Architecture-inspired wrapper for Rx.js+React
Stars: ✭ 22 (-69.01%)
Mutual labels: rxjs, flux
Evolui
A tiny reactive user interface library, built on top of RxJs.
Stars: ✭ 43 (-39.44%)
Mutual labels: rxjs
Fluxxkit
Unidirectional data flow for reactive programming in iOS.
Stars: ✭ 42 (-40.85%)
Mutual labels: flux
Nanoflux
A very lightweight and dependency-free Flux implementation
Stars: ✭ 56 (-21.13%)
Mutual labels: flux
Mill.jl
Multiple Instance Learning Library is build on top of Flux.jl aimed to prototype flexible multi-instance learning models.
Stars: ✭ 43 (-39.44%)
Mutual labels: flux
Rx Marble Design System
A design system to visualize functional reactive programming based on ReactiveExtensions
Stars: ✭ 60 (-15.49%)
Mutual labels: rxjs
Withobservables
HOC (Higher-Order Component) for connecting RxJS Observables to React Components
Stars: ✭ 41 (-42.25%)
Mutual labels: rxjs
Angular2 Take Until Destroy
Declarative way to unsubscribe from observables when the component destroyed
Stars: ✭ 40 (-43.66%)
Mutual labels: rxjs
Starter React Flux
Generate your React PWA project with TypeScript or JavaScript
Stars: ✭ 65 (-8.45%)
Mutual labels: flux
Angular1 Async Filter
Angular2 async pipe implemented as Angular 1 filter to handle promises & RxJS observables
Stars: ✭ 59 (-16.9%)
Mutual labels: rxjs
Until Destroy
🦊 RxJS operator that unsubscribe from observables on destroy
Stars: ✭ 1,071 (+1408.45%)
Mutual labels: rxjs
reactive-flux
Fluxish model implemented with RxJS
I was trying to use React + Flux to build a Dashboard but while reading Flux tutorials I already started to dislike the switch statements and constants that are all over the place.
React and the Flux architecture seem to fit well with RxJS, so this is my take on it.
This is my first JavaScript code so feel free to send pull requests and let me know of any bugs or improvements you can think of. It's inspired by several libraries that try to combine React with Rx but they didn't seem to do exactly what I had in mind.
Installation
npm install reactive-flux
Description
The dispatcher is completely gone. Instead we are using Rx.Subjects as Actions and Stores.
- An Action can have many Stores subscribed to it
- A Store can subscribe to many Actions, each with its own handler
- Additionally it can request to be notified after other stores in case there are any dependencies (Dispatcher.waitFor())
- React components can subscribe to many Stores as they are subclasses of Rx.Subject
Changelog
- 0.1.2: Custom function argument for Action. Fixed problem that the library could not be required correctly.
Example
let ReactiveFlux = require('reactive-flux'),
request = require('superagent'),
React = require('react'),
Action = ReactiveFlux.Action,
Store = ReactiveFlux.Store;
let LoginSucceededAction = Action.make();
let LoginFailedAction = Action.make();
let LoginAction = Action.make((username, password) => {
request
.post('/login')
.send({ username: username, password: password })
.end(function(err, res){
if (res.status == 200) {
LoginSucceededAction(res.body.token);
} else {
LoginFailedAction();
}
});
});
let LOGIN_TOKEN_KEY = 'token';
class LoginStore extends Store {
constructor() {
super();
// yes, I agree this is superfluous and needs to be changed :)
this.init();
}
init() {
this.observe(LoginSucceededAction, this.onLoginSucceeded);
this.observe(LoginFailedAction, this.onLoginFailed);
}
onLoginSucceeded(token) {
window.localStorage.setItem(LOGIN_TOKEN_KEY, token);
}
onLoginFailed() {
window.localStorage.removeItem(LOGIN_TOKEN_KEY);
}
getToken() {
return window.localStorage.getItem(LOGIN_TOKEN_KEY);
}
isLoggedIn() {
return !!this.getToken();
}
}
var LoginComponent = React.createClass({
getInitialState() {
return { isLoggedIn: LoginStore.isLoggedIn() };
},
_subscription: {},
componentDidMount() {
self = this;
this._subscription = LoginStore.subscribe(function () {
if (LoginStore.isLoggedIn()) {
// do something useful
}
});
},
componentWillUnmount() {
this._subscription.dispose();
},
render() {
return (
// something
);
},
handleSubmit(e) {
e.preventDefault();
let username = this.refs.username.getValue().trim();
let password = this.refs.password.getValue().trim();
if (!username || !password) {
return;
}
// call our action
LoginAction(username, password);
}
});
// Actions are subjects so we can subscribe to an API or similar
var source = Rx.Observable.fromEvent(document, 'mousemove');
source.subscribe(SomeAction); // All mousemove events will be send to subscribing stores of SomeAction
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].