All Projects → JuniperChicago → cycle-gun

JuniperChicago / cycle-gun

Licence: MIT license
A cycle.js driver wrapping gun.js storage

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to cycle-gun

cycle-snabbdom-examples
Cycle.js Component Examples with Routing & Transitions!
Stars: ✭ 13 (-50%)
Mutual labels:  xstream, cyclejs
Weapon-Detection-And-Classification
Weapon Detection & Classification through CCTV surveillance using Deep Learning-CNNs.
Stars: ✭ 53 (+103.85%)
Mutual labels:  gun
Xstream
An extremely intuitive, small, and fast functional reactive stream library for JavaScript
Stars: ✭ 2,259 (+8588.46%)
Mutual labels:  cyclejs
Cyclejs
A functional and reactive JavaScript framework for predictable code
Stars: ✭ 9,996 (+38346.15%)
Mutual labels:  cyclejs
Cycle.swift
An experiment in unidirectional architecture inspired by Cycle.js. https://cycle.js.org
Stars: ✭ 24 (-7.69%)
Mutual labels:  cyclejs
cycle-telegram
🚲 A Cycle.js Driver for Telegram Bot API
Stars: ✭ 19 (-26.92%)
Mutual labels:  cyclejs
recurrent
A library for building functional-reactive (FRP) GUIs in Clojurescript
Stars: ✭ 49 (+88.46%)
Mutual labels:  cyclejs
meeting-price-calculator
Meeting Price Calculator - How expensive are meetings, really?
Stars: ✭ 17 (-34.62%)
Mutual labels:  cyclejs
cycle-audio-graph
Audio graph driver for Cycle.js based on virtual-audio-graph
Stars: ✭ 19 (-26.92%)
Mutual labels:  cyclejs
cyclejs-sortable
Makes all children of a selected component sortable
Stars: ✭ 16 (-38.46%)
Mutual labels:  cyclejs
cycle-hn
Hackernews Clone Using CycleJS
Stars: ✭ 42 (+61.54%)
Mutual labels:  cyclejs
Guns
Guns基于SpringBoot 2,致力于做更简洁的后台管理系统,完美整合springmvc + shiro + mybatis-plus + beetl!Guns项目代码简洁,注释丰富,上手容易,同时Guns包含许多基础模块(用户管理,角色管理,部门管理,字典管理等10个模块),可以直接作为一个后台管理系统的脚手架!
Stars: ✭ 3,327 (+12696.15%)
Mutual labels:  gun
SpaceInvadersEcs
Simple example of SpaceInvaders(Guns&Bullets variation) game using Entity-Component-System implementation by Leopotam. It's fine example how to use Leopotam ECS framework and how to use ECS-architecture in your game at all
Stars: ✭ 15 (-42.31%)
Mutual labels:  gun
gun-scape
GunDB Cytoscape Graph Visualizer + Live Editor
Stars: ✭ 49 (+88.46%)
Mutual labels:  gun
kibana graph
Interactive Network Graph Visualization For Kibana (unmaintained)
Stars: ✭ 38 (+46.15%)
Mutual labels:  gun
gunstore.io
Store your data in Gun DB by sending simple HTTP requests - based on jsonstore.io 💾 🚀
Stars: ✭ 32 (+23.08%)
Mutual labels:  gun
meanOs
Mean Operating System - The first decentralized, artificially intelligent, MEAN.js stack, operating system. Mean OS is the only operating system hosted anonymous using a P2P network and a suite of non-standard in-browser delivery mechanisms. Mean OS proudly supports Brave and Tor, be free!
Stars: ✭ 62 (+138.46%)
Mutual labels:  gun
machine gun
HTTP/1 and HTTP/2 client for Elixir. Based on Gun and Poolboy.
Stars: ✭ 62 (+138.46%)
Mutual labels:  gun
gun-cassandra
Cassandra / Elassandra persistence layer for Gun DB 🔫
Stars: ✭ 14 (-46.15%)
Mutual labels:  gun

cycle-gun

A cycle.js driver that wraps a gun.js store instance.

Note: This driver currently depends on the xstream library.

Overview

  • Gun.js store is created inside a cycle driver pointing to an optional peer.
  • The source from the Gun driver is an object with 3 methods: select, shallow, and each
  • The sink stream emits "command" functions which take the gun.js instance and apply some changes to it using the normal Gun.js API

Installation

npm install --save cycle-gun

GunSource

The source from the Gun.js driver is an object with some methods that return streams.

Use gunSource.select('books') to go to the books path in the graph. It returns a new gunSource object.

Use gunSource.shallow() to get a Stream of the data under the current path. This is equivalent to Gun's .on(callback) API.

const presidentAge$ = sources.gun
  .select('president').shallow()
  .map(x => {
    // x is the data for `president`
    return x.age;
  })

Use gunSource.each() to get a Stream of the data under each child property of the current path. This is equivalent to Gun's .map().on(callback) API. The return stream will emit an object {key, value}. This method is useful when the current path points to a set of many resources.

const book$ = sources.gun
  .select('books').each()
  .map(x => {
    // x is an object {key, value} representing ONE book
    return x.value;
  })

Sinking commands to gun driver

In this version, we can send commands to the gun driver by sending a function through the sink stream with payload references.

const outgoingGunTodo$ = event$
  .map((event) => function command(gunInstance) {
    return gunInstance
      .get('example/todo/data')
      .path(uuid())
      .put(event.payload);
  })

A more detailed example

Note: virtual-dom details omitted and transducers are verbose here

import xs from 'xstream';
import { run } from '@cycle/run';
//import { makeDOMDriver } from '@cycle/dom';
import { makeGunDriver } from 'cycle-gun';
import * as uuid from 'uuid-random';
import * as equal from 'deep-equal';
import dropRepeats from 'xstream/extra/dropRepeats';

function main(sources) {

  const {DOM, gun} = sources;

  const gunTodoEvent$ = sources.gun
    .select('example').select('todo').select('data')
    .shallow();

  // map gun driver events into messages, or return as state
  const gunState$ = gunTodoEvent$
    .compose(dropRepeats(equal))
    .map((event) => {
      return { typeKey: 'getTodo', payload: event };
    })

  // sink gunState$ into a flux-type store or into vdom




  // sink map filtered stream of payloads into function and emit function
  const outgoingGunEvents$ = event$
    .filter(event => event.typeKey === 'putTodo')
    .map((event) => {
      return (gunInstance) => {
        return gunInstance.get('example/todo/data').path(uuid()).put(event.payload);
      }
    })

  return {
    // DOM: vtree$
    gun: outgoingGunEvents$
  };
}

const drivers = {
  // DOM: makeDOMDriver('#app'),
  gun: makeGunDriver({root: 'root', peers: ['http://localhost:3500']})
};

run(main, drivers);

Other cyclejs reources

Please see awesome-cyclejs - A curated list of awesome Cycle.js resources.

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].