0.0.0 • Published 7 years ago

@ipfn/session v0.0.0

Weekly downloads
-
License
-
Repository
github
Last release
7 years ago

IPFN Neuron firings Session in JavaScript

IPFN project Dependency Status Dev Dependency Status Circle CI

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.