kesen
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i kesen

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

273 kB

Total Files

31

Last publish

Collaborators

  • plitex