/ archiveofbelonging.org / back / node_modules / brcast /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]dist/2 years ago -  
[TXT]CHANGELOG.md8 years ago1.6K 
[   ]LICENSE8 years ago1.1K7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك]
[TXT]README.md8 years ago2.5Kf12eb36 documentaiton updates [كارل مبارك]
[   ]index.js8 years ago956  
[   ]index.spec.js8 years ago2.9K 
[   ]package.json2 years ago2.9K7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك]
README.md

Brcast

Tiny data broadcaster with 0 dependencies

Travis Code Coverage David npm npm JavaScript Style Guide MIT License

The current size of brcast/dist/brcast.umd.min.js is:

gzip size

It's like a data store you can subscribe to, with a setter to pump data in. For browsers and node.

Table of Contents

Install

This project uses node and npm. Go check them out if you don't have them locally installed.

$ npm install --save brcast

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import brcast from 'brcast'

// using CommonJS modules
var brcast = require('brcast')

The UMD build is also available on unpkg:

<script src="https://unpkg.com/brcast/dist/brcast.umd.js"></script>

You can find the library on window.brcast.

Usage

import brcast from 'brcast'

let broadcast = brcast()

// subscribe
let unsubscribe = broadcast.subscribe(state => console.log(state))

// setState sets the state and invoke all subscription callbacks passing in the state
broadcast.setState(1)

// setState returns the current state
broadcast.getState()

// unsubscribe: invoke the function returned by broadcast.subscribe(state => console.log(state))
// to unbind the handler
unsubscribe()

Tests

$ npm run test

MIT License © Alessandro Arnodo

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80