All Projects → AvraamMavridis → Dugong

AvraamMavridis / Dugong

Minimal State Store Manager for React Apps using RxJS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Dugong

Ayanami
🍭 A better way to react with state
Stars: ✭ 129 (+1190%)
Mutual labels:  reactive, rxjs, decorators
rx-ease
Spring animation operator for rxjs 🦚✨
Stars: ✭ 16 (+60%)
Mutual labels:  reactive, rxjs
vue-rxjs
Yet another rxjs binding library for Vue.js
Stars: ✭ 14 (+40%)
Mutual labels:  reactive, rxjs
Awesome Rxjs
A collection of awesome RxJS resources
Stars: ✭ 314 (+3040%)
Mutual labels:  reactive, rxjs
Platform
Reactive libraries for Angular
Stars: ✭ 7,020 (+70100%)
Mutual labels:  reactive, rxjs
juliette
Reactive State Management Powered by RxJS
Stars: ✭ 84 (+740%)
Mutual labels:  reactive, rxjs
Toy Rx
A tiny implementation of RxJS that actually works, for learning
Stars: ✭ 290 (+2800%)
Mutual labels:  reactive, rxjs
bassdrum
reactive, type safe components with preact and rxjs.
Stars: ✭ 44 (+340%)
Mutual labels:  reactive, rxjs
Formily
Alibaba Group Unified Form Solution -- Support React/ReactNative/Vue2/Vue3
Stars: ✭ 6,554 (+65440%)
Mutual labels:  reactive, rxjs
Motion
Reactive frontend UI components for Rails in pure Ruby
Stars: ✭ 498 (+4880%)
Mutual labels:  reactive, component
Xreact
reactive x react = xreact
Stars: ✭ 565 (+5550%)
Mutual labels:  reactive, rxjs
reactive-search
Incremental search using React and RxJS
Stars: ✭ 15 (+50%)
Mutual labels:  reactive, rxjs
drawer
A touch-enabled drawer component for the modern web.
Stars: ✭ 26 (+160%)
Mutual labels:  reactive, rxjs
rxdeep
rxjs deep state management
Stars: ✭ 47 (+370%)
Mutual labels:  reactive, rxjs
reactive-graphql
A GraphQL implementation based around RxJS, very well suited for client side only GraphQL usage
Stars: ✭ 58 (+480%)
Mutual labels:  reactive, rxjs
bind-observable
Provides a typescript decorator which binds class properties to observable companion properties.
Stars: ✭ 15 (+50%)
Mutual labels:  rxjs, decorators
Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+7770%)
Mutual labels:  reactive, rxjs
redrock
Typesafe, reactive redux
Stars: ✭ 14 (+40%)
Mutual labels:  reactive, rxjs
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (+310%)
Mutual labels:  reactive, decorators
Ngx Auto Unsubscribe
Class decorator that will automatically unsubscribe from observables
Stars: ✭ 337 (+3270%)
Mutual labels:  rxjs, decorators

Dugong

Minimal State Container for React Apps using RxJS

NPM

Dugong

npm version Build Status CocoaPods semantic-versioning Greenkeeper badge

Dugong is a minimal single-store state container for React that uses RxJS. You can use it with Redux/Flux or any other pattern/framework although that is not nessecary.

Why Dugong?

I made Dugong because I wanted a more clear way to know what every component consumes from the global state. Passing attributes through the props in apps with deep hierarchies many times leads to confusion and decrease the developement speed. Imagine a scenario where you have to inspect the parent of the parent of the parent of a component to know why a property is passed to it and if its value is the same as the value that the parent have or if the parent has manipulate it. Ofcourse you can still pass props from the parents, it is just my opinion that you should avoid it. Also I wanted to be able to have a Store on which I can iterate using reactive programming methods.

How to pass the data from the Store to the Components

Create your Store with its initial state
import { createStore } from 'dugong';

const initialState =  {
  ui: { ... },
  businessLogic: { ... },
  hello: "hello world",
  ...
  ...
};

createStore( initialState );
Connect your component with the Store and define which parameters of the store you want to listen.
import { connect } from 'dugong';

@connect( 'hello' )
class MyHelloWorldComponent extends Component
{
  render(){
    return <div>{ this.state.hello }</div>;
  }
}
You can also get the Store and use rxjs methods on it.
import { getStore } from 'dugong';

class MyHelloWorldComponent extends Component
{
  componentWillMount()
  {
    getStore().map( ( { ui } ) => ui.something )
              .filter( something => something.length > 4 )
              .subscribe( something => this.setState( { something } ) );
  }
  render(){
    return <div>{ this.state.something }</div>;
  }
}

How to update the Store

Dugong is not opinionated on how to structure your application, you can use updateStore() directly inside the components.
import { updateStore } from 'dugong';

class MyComponent extends Component
{
  update( something )
  {
     updateStore( { something } );
  }
  render(){
    return <input onChange={ e => this.updateStore( e.target.value ) }</input>;
  }
}
You can create services that will update parts of the store and inject them inside your components
// UIService
import { updateStore } from 'dugong';

export const updateSomething = value => updateStore( { something : value } );


// MyComponent
import UIService from 'dugong';

class MyComponent extends Component
{
  update( value )
  {
     UIService.updateSomething( value );
  }
  render(){
    return <input onChange={ e => this.updateStore( e.target.value ) }</input>;
  }
}
...or you can even dispatch an action with Redux (or anything similar) and then use updateStore to change the global state of your application.

Contributing

Feel free to open issues, make suggestions or send PRs. This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code.

Contact

E-mail : [email protected]

Twitter: @avraamakis

License

MIT

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].