Top Related Projects
A Javascript library for state management in React applications
A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
Isomorphic flux implementation
A JS library for predictable global state management
Application Architecture for Building User Interfaces
A pluggable container for universal flux applications.
Quick Overview
Fluxxor is a set of tools for implementing the Flux architecture in JavaScript applications, particularly for use with React. It provides a streamlined way to manage application state and data flow, making it easier to build scalable and maintainable user interfaces.
Pros
- Simplifies implementation of the Flux architecture
- Provides a clear and consistent data flow pattern
- Integrates well with React applications
- Lightweight and easy to learn
Cons
- Less active development and community support compared to newer state management libraries
- May be overkill for small applications
- Limited ecosystem of plugins and extensions
- Some developers may find the boilerplate code repetitive
Code Examples
- Creating a Fluxxor store:
var TodoStore = Fluxxor.createStore({
initialize: function() {
this.todos = [];
this.bindActions(
"ADD_TODO", this.onAddTodo,
"TOGGLE_TODO", this.onToggleTodo
);
},
onAddTodo: function(payload) {
this.todos.push({text: payload.text, complete: false});
this.emit("change");
},
onToggleTodo: function(payload) {
this.todos[payload.index].complete = !this.todos[payload.index].complete;
this.emit("change");
},
getState: function() {
return {
todos: this.todos
};
}
});
- Creating Fluxxor actions:
var actions = {
addTodo: function(text) {
this.dispatch("ADD_TODO", {text: text});
},
toggleTodo: function(index) {
this.dispatch("TOGGLE_TODO", {index: index});
}
};
- Integrating Fluxxor with a React component:
var FluxMixin = Fluxxor.FluxMixin(React),
StoreWatchMixin = Fluxxor.StoreWatchMixin;
var TodoApp = React.createClass({
mixins: [FluxMixin, StoreWatchMixin("TodoStore")],
getStateFromFlux: function() {
var flux = this.getFlux();
return flux.store("TodoStore").getState();
},
render: function() {
return (
<div>
<ul>
{this.state.todos.map(function(todo, i) {
return <li key={i}>{todo.text}</li>;
})}
</ul>
</div>
);
}
});
Getting Started
To get started with Fluxxor:
-
Install Fluxxor:
npm install fluxxor
-
Create stores, actions, and set up the Flux instance:
var stores = { TodoStore: new TodoStore() }; var flux = new Fluxxor.Flux(stores, actions);
-
Use the Flux instance in your React application:
React.render(<TodoApp flux={flux} />, document.getElementById("app"));
Competitor Comparisons
A Javascript library for state management in React applications
Pros of Marty
- More comprehensive state management solution with built-in support for isomorphic applications
- Better integration with React, including higher-order components and container components
- More active development and community support
Cons of Marty
- Steeper learning curve due to more complex architecture
- Potentially more boilerplate code required for setup and configuration
- Less flexibility in terms of customization compared to Fluxxor's simpler approach
Code Comparison
Fluxxor:
var actions = {
addTodo: function(text) {
this.dispatch('ADD_TODO', {text: text});
}
};
var TodoStore = Fluxxor.createStore({
initialize: function() {
this.todos = [];
this.bindActions('ADD_TODO', this.onAddTodo);
},
onAddTodo: function(payload) {
this.todos.push({text: payload.text});
this.emit('change');
}
});
Marty:
class TodoActions extends Marty.ActionCreators {
addTodo(text) {
this.dispatch(TodoConstants.ADD_TODO, text);
}
}
class TodoStore extends Marty.Store {
constructor(options) {
super(options);
this.state = {todos: []};
this.handlers = {
addTodo: TodoConstants.ADD_TODO
};
}
addTodo(text) {
this.state.todos.push({text: text});
}
}
A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
Pros of Refluxjs
- Simpler API with less boilerplate code
- More flexible architecture allowing for easier customization
- Better integration with React's component lifecycle
Cons of Refluxjs
- Less opinionated structure, which may lead to inconsistent implementations
- Lacks built-in support for immutable data structures
- May require additional libraries for more complex state management scenarios
Code Comparison
Refluxjs:
var Actions = Reflux.createActions([
"increment",
"decrement"
]);
var CounterStore = Reflux.createStore({
listenables: Actions,
onIncrement: function() {
this.trigger(this.count++);
}
});
Fluxxor:
var constants = {
INCREMENT: "INCREMENT",
DECREMENT: "DECREMENT"
};
var actions = {
increment: function() {
this.dispatch(constants.INCREMENT, {amount: 1});
}
};
var CounterStore = Fluxxor.createStore({
initialize: function() {
this.count = 0;
this.bindActions(constants.INCREMENT, this.onIncrement);
},
onIncrement: function(payload) {
this.count += payload.amount;
this.emit("change");
}
});
Both Refluxjs and Fluxxor are Flux implementations for React applications, but they differ in their approach to state management. Refluxjs offers a more streamlined API and greater flexibility, while Fluxxor provides a more structured and opinionated framework. The choice between the two depends on the specific needs of the project and the development team's preferences.
Isomorphic flux implementation
Pros of Alt
- More lightweight and flexible architecture
- Better TypeScript support and type inference
- Easier to test due to simpler store structure
Cons of Alt
- Less opinionated, which may lead to inconsistent implementations
- Steeper learning curve for developers new to Flux architecture
- Smaller community and fewer resources compared to Fluxxor
Code Comparison
Alt:
class MyStore {
constructor() {
this.bindListeners({
handleUpdateName: MyActions.UPDATE_NAME
});
this.name = 'Default';
}
handleUpdateName(name) {
this.name = name;
}
}
Fluxxor:
var MyStore = Fluxxor.createStore({
initialize: function() {
this.name = 'Default';
this.bindActions(
'UPDATE_NAME', this.onUpdateName
);
},
onUpdateName: function(payload) {
this.name = payload.name;
this.emit('change');
}
});
Both Alt and Fluxxor are Flux implementations for React applications. Alt offers a more modern and flexible approach, while Fluxxor provides a more structured and opinionated framework. The code comparison shows that Alt uses a class-based approach, while Fluxxor uses a more traditional object-based structure. Alt's syntax is generally more concise and closer to modern JavaScript practices.
A JS library for predictable global state management
Pros of Redux
- Larger community and ecosystem, with more resources and third-party tools
- Simpler API and learning curve, making it easier for beginners to adopt
- Better integration with React through react-redux library
Cons of Redux
- More boilerplate code required for setup and state management
- Less flexibility in handling complex state updates compared to Fluxxor's Flux stores
- Can be overkill for smaller applications with simple state management needs
Code Comparison
Redux:
const reducer = (state = initialState, action) => {
switch (action.type) {
case 'INCREMENT':
return { ...state, count: state.count + 1 };
default:
return state;
}
};
Fluxxor:
var CounterStore = Fluxxor.createStore({
initialize: function() {
this.count = 0;
this.bindActions("INCREMENT", this.onIncrement);
},
onIncrement: function() {
this.count++;
this.emit("change");
}
});
Both Redux and Fluxxor are state management libraries for JavaScript applications, but they differ in their implementation of the Flux architecture. Redux offers a more streamlined approach with a single store and pure reducer functions, while Fluxxor provides a more traditional Flux implementation with multiple stores and actions. The choice between the two depends on the specific needs of the project and the developer's familiarity with Flux concepts.
Application Architecture for Building User Interfaces
Pros of Flux
- Official implementation by Facebook, ensuring alignment with React ecosystem
- More comprehensive documentation and examples
- Larger community support and ecosystem of tools
Cons of Flux
- More complex architecture, potentially steeper learning curve
- Less opinionated, requiring more boilerplate code
- Lack of built-in features like automatic action creation
Code Comparison
Flux:
var AppDispatcher = require('./AppDispatcher');
var Constants = require('./Constants');
var TodoActions = {
create: function(text) {
AppDispatcher.dispatch({
actionType: Constants.TODO_CREATE,
text: text
});
}
};
Fluxxor:
var actions = {
addTodo: function(text) {
this.dispatch('ADD_TODO', {text: text});
}
};
var flux = new Fluxxor.Flux(stores, actions);
Flux requires more setup and boilerplate, while Fluxxor provides a more concise API for defining actions and stores. Flux's approach offers more flexibility but can be more verbose, whereas Fluxxor simplifies the implementation with its opinionated structure.
Both libraries aim to implement the Flux architecture, but Fluxxor offers a more streamlined experience with less setup required. Flux, being the reference implementation, provides a solid foundation for understanding the core concepts and allows for more customization in larger applications.
A pluggable container for universal flux applications.
Pros of Fluxible
- More actively maintained with recent updates and releases
- Offers isomorphic/universal JavaScript support out of the box
- Provides a plugin system for extending functionality
Cons of Fluxible
- Steeper learning curve due to more complex architecture
- Requires additional setup and configuration compared to Fluxxor
- Less straightforward implementation of stores and actions
Code Comparison
Fluxxor store creation:
var TodoStore = Fluxxor.createStore({
initialize: function() {
this.todos = [];
this.bindActions(
"ADD_TODO", this.onAddTodo,
"TOGGLE_TODO", this.onToggleTodo
);
},
// ... store methods
});
Fluxible store creation:
class TodoStore extends BaseStore {
constructor(dispatcher) {
super(dispatcher);
this.todos = [];
}
handleAddTodo(payload) {
// ... handle action
}
handleToggleTodo(payload) {
// ... handle action
}
}
TodoStore.storeName = 'TodoStore';
TodoStore.handlers = {
'ADD_TODO': 'handleAddTodo',
'TOGGLE_TODO': 'handleToggleTodo'
};
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Fluxxor is a set of tools to aid in developing React applications with the Flux architecture.
Installation
Fluxxor is available on npm and works with module bundlers like Browserify and Webpack.
npm install [--save] fluxxor
Standalone browser builds can be downloaded from the GitHub releases page or installed via Bower:
bower install fluxxor
More detailed installation instructions can be found on the Fluxxor website.
Third Party Releases
The following releases are maintained by third parties, and support inquiries should be directed to their maintainers.
WebJar
For JVM languages, there are WebJar packages available on Maven Central and jsDelivr as the following:
SBT/Play Framework 2:
"org.webjars" % "fluxxor" % fluxxorVersion
Maven:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>fluxxor</artifactId>
<version>${fluxxor.version}</version>
</dependency>
For detailed instructions, refer to the WebJars documentation. For update requests, open a pull request on the Fluxxor WebJar repository on Github.
Browser Compatibility
Fluxxor is compatible with any ES5-compliant browser (IE 9+, FF 4+, Safari 5.1.4+, Chrome 19+, Opera 12.10+). You can use es5-shim for other browsers.
Documentation
See the Fluxxor website for in-depth documentation, installation instructions, examples, and a getting started guide.
Support and Chat
Get help with and chat about Fluxxor on Gitter.
License
Fluxxor is licensed under the MIT license.
The MIT License (MIT)
Copyright (c) 2014 Michelle Tilley
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Top Related Projects
A Javascript library for state management in React applications
A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
Isomorphic flux implementation
A JS library for predictable global state management
Application Architecture for Building User Interfaces
A pluggable container for universal flux applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot