@ipfn/session
v0.0.0
Published
[![IPFN project](https://img.shields.io/badge/project-IPFN-blue.svg?style=flat-square)](http://github.com/ipfn) [![Dependency Status](https://david-dm.org/ipfn/js-ipfn-session.svg?style=flat-square)](https://david-dm.org/ipfn/js-ipfn-session) [![Dev Depen
Downloads
3
Readme
IPFN Neuron firings Session in JavaScript
IPFN neurons runtime session in JavaScript.
Install
This project is available through npm. To install run:
> npm install @ipfn/session
Usage
import Session from '@ipfn/session';
import SynapticTypes from '@ipfn/synaptic-types';
import { neuron, synaptic } from '@ipfn/neurons';
import { fire, subscribe, lookup } from '@ipfn/runtime';
// const c = 'QmY3JV1FWbKLyr4SaRpbKpB1J1JEEyTTB3oZTTxAsF8gJC';
// Create a new session of firings
const session = new Session(keys);
// Lookup `Counter` neuron
const counter = lookup('QmY3JV1FWbKLyr4SaRpbKpB1J1JEEyTTB3oZTTxAsF8gJC/Counter');
// We will log to console all firings during this session
subscribe(session, counter.increment.count, count => {
console.log(`Incremented to ${count}`);
});
// Fire `5` on `count` input on `increment` neuron
fire(session, counter.increment.count, 5);
See package tests for more examples.