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

storeon

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storeon - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

4

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 0.7
* Move event typo check to `devtools`.
* Reduce size.
## 0.6

@@ -5,0 +9,0 @@ * Allow to pass DevTools options.

@@ -20,2 +20,3 @@ /**

window.top.__REDUX_DEVTOOLS_EXTENSION__
if (!extension) {

@@ -31,3 +32,3 @@ if (process.env.NODE_ENV !== 'production') {

var ReduxTool = extension.connect(options)
var ReduxTool = extension.connect()
store.on('@init', function () {

@@ -46,2 +47,5 @@ ReduxTool.subscribe(function (message) {

if (event !== 'UPDATE_FROM_DEVTOOLS' && prev !== 'UPDATE_FROM_DEVTOOLS') {
if (event[0] !== '@' && (!data[2] || data[2].length === 0)) {
throw new Error('Unknown Storeon event ' + event)
}
if (event !== '@changed' || Object.keys(data[1]).length) {

@@ -48,0 +52,0 @@ ReduxTool.send({ type: event, payload: data[1] }, state)

27

index.js

@@ -21,7 +21,7 @@ /**

*/
function createStore (modules) {
var createStore = function (modules) {
var events = { }
var state = { }
function on (event, cb) {
var on = function (event, cb) {
if (!events[event]) {

@@ -39,13 +39,7 @@ events[event] = [cb]

function dispatch (event, data) {
var dispatch = function (event, data) {
if (event !== '@dispatch') {
dispatch('@dispatch', [event, data])
dispatch('@dispatch', [event, data, events[event]])
}
if (process.env.NODE_ENV !== 'production') {
if (event.indexOf('@') !== 0 && !events[event]) {
throw new Error('Unknown Storeon event ' + event)
}
}
if (events[event]) {

@@ -57,7 +51,6 @@ var changes = { }

if (diff) {
changed = true
var newState = { }
for (key in state) newState[key] = state[key]
for (key in diff) newState[key] = changes[key] = diff[key]
state = newState
changed = { }
for (key in state) changed[key] = state[key]
for (key in diff) changed[key] = changes[key] = diff[key]
state = changed
}

@@ -69,7 +62,7 @@ })

function get () {
var get = function () {
return state
}
var store = { on: on, dispatch: dispatch, get: get }
var store = { dispatch: dispatch, get: get, on: on }

@@ -76,0 +69,0 @@ modules.forEach(function (i) {

{
"name": "storeon",
"version": "0.6.0",
"description": "Tiny (175 bytes) event-based Redux-like state manager for React and Preact",
"version": "0.7.0",
"description": "Tiny (174 bytes) event-based Redux-like state manager for React and Preact",
"keywords": [

@@ -6,0 +6,0 @@ "state",

@@ -5,3 +5,3 @@ # Storeon

* **Small.** 175 bytes (minified and gzipped). No dependencies.
* **Small.** 174 bytes (minified and gzipped). No dependencies.
It uses [Size Limit] to control size.

@@ -56,6 +56,10 @@ * **Fast.** It tracks what parts of state were changed and re-renders

## Usage
## Install
### Store
```sh
npm install storeon
```
## Store
The store should be created with `createStore()` function. It accepts a list

@@ -96,3 +100,3 @@ of the modules.

### Events
## Events

@@ -167,3 +171,3 @@ There are three built-in events:

### Components
## Components

@@ -210,3 +214,3 @@ For functional components, `useStoreon` hook will be the best option:

### DevTools
## DevTools

@@ -222,5 +226,7 @@ Storeon supports debugging with [Redux DevTools Extension].

DevTools will also warn you about **typo in event name**. It will throw an error
if you are dispatching event, but nobody subscribed to it.
Or if you want to print events to `console` you can use built-in logger.
It could be useful for simple cases or to investigate issue
on online error trackers.
It could be useful for simple cases or to investigate issue in error trackers.

@@ -227,0 +233,0 @@ ```js

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