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

storeon-choo

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storeon-choo

A tiny (81 bytes) connector for Storeon and Choo

  • 0.2.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Storeon Choo

npm version Build Status

Storeon logo by Anton Lovchikov

A tiny connector for Storeon and Choo.

Size is only 81 bytes (minified and gzipped). It uses Size Limit to control size.

Read more about Storeon article.

Install

npm install -S storeon-choo

or

yarn add storeon-choo

How to use (Demo)

Create store using storeon module:

store.js
import { createStoreon } from 'storeon'

let counter = store => {
  store.on('@init', () => ({ count: 0 }))
  store.on('inc', ({ count }) => ({ count: count + 1 }))
}

export const store = createStoreon([counter])
index.js

Use storeonMiddleware from storeon-choo.

import choo from 'choo'
import storeonMiddleware from 'storeon-choo'
import { store } from './store'

const app = choo()
app.use(storeonMiddleware(store))
app.route('/', require('./views/main'))

module.exports = app.mount('body')

Emitting @dispatch event with payload (like [event, data]) you will dispatch storeon event. All states are located in state.storeon property.

main.js
import html from 'choo/html'

export default function view(state, emit) {
  const increment = () => emit('@dispatch', ['inc'])

  return html`
    <body>
      <h1>Count: ${state.storeon.count}</h1>
      <button onclick=${increment}></button>
    </body>
  `
}

FAQs

Package last updated on 21 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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