0.6.0 • Published 5 years ago

@kadabra/client v0.6.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Kadabra Client

Connect to a kadabra server.

npm i --save @kadabra/client

Setup

import client from '@kadabra/client'
let kadabra = client() // connect to local Kadabra server
// OR 
let kadabra = client('foo.com:7777') // connect to other kadabra or feathers server

Quick Example

kadabra().authenticate({ email: "merlin@camelot", password: "Xcal!ber" })

let spellbook = []
kadabra('spells')
  .find({ query: { element: "Fire" } })
  .then(fireSpells => spellbook.concat(fireSpells))

kadabra().logout()

API

Kadabra is built on top of Feathers. Refer to Feathers Service Methods Documentation for further detail if needed, but in most cases this is enough without reading it:

get(id)
find() // "get many"; see feathers docs for how to query
create(obj) 
remove(id) // Note that id is now required. use removeMany(params) to remove many records
update(id, obj) // replace current object
patch(id, obj)  // merge into current object

Kadabra also leverages feathers-reactive and feathers authentication client to add:

watch() // see feathers-reactive or see below
authenticate({ email: 'foo', password: 'bar' }) // Call once to (re)authenticate
logout()

Realtime Example

let potions = []
let subscription = kadabra('potions')
  .watch() // after watch(), find and get return observables you subscribe to
  .find()
  .subscribe(pots => { potions = pots }) // this will be re-ran every update

This pattern is so common that we provide this helper methods:

let subscription = kadabra('scrolls')
  .stream(scroll => alert('Found ' + scroll))

Note - The subscription object has an .unsubscribe() method to cancel that subscription!

0.6.0

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago