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

heridux

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heridux - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

26

lib/index.js

@@ -1,3 +0,4 @@

import { combineReducers } from "redux"
import { createStore, combineReducers } from "redux"
import { fromJS } from "immutable"
/**

@@ -9,5 +10,19 @@ * Création d'un store partiel et réutilisable

static connect(store, reducers) {
static createReduxStore(reducer, preloadedState, enhancer) {
const DEVTOOLS = window.__REDUX_DEVTOOLS_EXTENSION__
reducer = reducer || ((state = {}) => state)
Heridux._globalStore = createStore(
reducer,
preloadedState,
enhancer || (DEVTOOLS && DEVTOOLS())
)
Heridux._reducers = reducer
}
static connect(store, initialReducers) {
Heridux._globalStore = store
Heridux._reducers = reducers
Heridux._reducers = initialReducers
}

@@ -243,2 +258,5 @@

}
subscribe(callback) {
return Heridux._globalStore.subscribe(callback)
}
}

9

package.json
{
"name": "heridux",
"version": "0.0.1",
"version": "0.0.2",
"description": "the simpliest way to use and reuse redux stores",

@@ -11,4 +11,5 @@ "main": "lib/index.js",

"eslint": "^5.16.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-node-globals": "^1.4.0"
"rollup-watch": "^4.3.1"
},

@@ -18,3 +19,7 @@ "dependencies": {

"redux": "^4.0.1"
},
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w"
}
}

@@ -1,2 +0,37 @@

# heridux
The simpliest way to use and reuse redux stores
# Heridux
The simpliest way to use and reuse redux stores.
See especially [react-heridux](https://github.com/YannickBochatay/react-heridux).
### Installation
With npm or yarn.
```shell
npm install heridux
```
```shell
yarn install heridux
```
### Basic example
```javascript
import Heridux from "heridux"
Heridux.createReduxStore() //create global redux store
const hStore = new Heridux("keyForPartialStore") // create as many partial stores as you want
hStore.setInitialState({ counter : 0 }) // state will be converted to Immutable
hStore.createAction("increment", state => ( // define your actions
state.update("counter", state.get("counter") + 1)
))
hStore.createAction("decrement", state => (
state.set("counter", state.get("counter") - 1)
))
hStore.register() // register this store to the global redux store
```
### Example in action
[http://yannickbochatay.github.io/heridux](http://yannickbochatay.github.io/heridux/)

@@ -6,7 +6,5 @@ import nodeResolve from "rollup-plugin-node-resolve"

input: 'lib/index.js',
output: {
file: 'build.js',
format: 'esm'
},
dest: 'bundle.js',
format: 'esm',
plugins :[nodeResolve(), nodeGlobals()]
}
import Heridux from "./build.js"
console.log("Heridux found !", Heridux)
Heridux.createReduxStore()
const hStore = new Heridux("counterStore")
hStore.setInitialState({ counter : 0 })
hStore.createAction("increment", state => (
state.set("counter", state.get("counter") + 1)
))
hStore.createAction("decrement", state => (
state.set("counter", state.get("counter") - 1)
))
hStore.register()
///////////////////////////////////////////////////////////
const valueEl = document.getElementById('value')
const render = () => valueEl.innerHTML = hStore.get("counter")
render()
hStore.subscribe(render)
document.getElementById('increment')
.addEventListener('click', () => hStore.execAction("increment"))
document.getElementById('decrement')
.addEventListener('click', () => hStore.execAction("decrement"))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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