0.2.0 • Published 6 years ago

kesen v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Kesen (WORK IN PROGRESS)

An isomorphic Javascript DDP Client

Install

$ yarn add kesen

How to use

Auto init (Browser only):

import Kesen, { Collection } from 'kesen';

// Create a collection
const Tasks = new Collection('tasks');

// Call a method
Kesen.call('insertTask', 'Destroy asteroids').then(
  result => console.log(result),
  error => console.log('Error:', error)
);

// Subscribe to reactive data
Kesen.track(subscribe => {
  const subsHandle = subscribe('tasks');
  if (subsHandle.ready()) {
    console.log(Tasks.find().all());
  }
});

Custom init (default client):

import { createClient, Collection } from 'kesen';

createClient('default', `ws//myhost:7890/ws`);

// Create a collection
const Tasks = new Collection('tasks');

// Call a method
Kesen.call('insertTask', 'Destroy asteroids').then(
  result => console.log(result),
  error => console.log('Error:', error)
);

// Subscribe to reactive data
Kesen.track(subscribe => {
  const subsHandle = subscribe('tasks');
  if (subsHandle.ready()) {
    console.log(Tasks.find().all());
  }
});

Examples

Simple Todos React