hub.js
Observable data structures, over the network
What is it not?
- Its not a database
- Its not a query language
- Its not persistent storage
What is it?
- Software to help scale a realtime back end to millions of users — without adding any extra worries for developers
- Make an app for users as simple as creating a prototype
- Use the server to offload most of your client side cpu
Why
There is firebase right?
- better subscriptions, “observable deep queries”
- conflict resolution
- flexible
- completely open source — can be hosted on now or anywhere else
- use as a hub for all your integrations — custom AND standard
What does it do?
- Create realtime branches of data
- Gives sandboxes for your application to store data in
- Executes queries
- Sends diffs, keeps track of change
- Integrates apis
- Supports references (serliazable over the network)
- Performs!
- Can be a server
- Can be a client
- Or both
- Runs on the browser
- Can be used as a state store (like redux but simple)
- Reconnects
- Server side sessions
Getting started
npm i hub.js
const Hub = // creates a hub as a server and as a clientconst hub =
Data structure
hub.js uses a data structure modelled to closely resemble plain js objects
Elements can be values and objects at the same time, all element are observable
const hub = // .set does a deep merge by defaulthub hub // object notation for listenershub console // serialize casts hub objects to plain objects// logs { something: { val: 'hello', field: 'some field' }}
References
const hub = // creates an observable referencehub hubthing hubsomething// fires the listener on hub.thing hub// set something to a reference before it exists hub// will resolve updates for
Subscriptions
Basic
A simple subscription
client
Setting on the server
server// will fire an update on client
A shallow subscription
client
Any
A simple subscription
client
A complex subscription
client
A complex subscription with sort
client
Switch
Switches are probably the most powerful concept in supported in the subscription model, allowing you to branch subscriptions based on certain conditions
client