Nesquirk
Ties Nes + minimongo together for gloryful reactive apps.
Server
const Hapi = const Nesquirk = const server = server server
Managing the subscription
We don't keep subscription documents in memory, so you have to maintain your subscriptions, just like with Nes
.
// Single item (_id) must be in the url, or in the update obj to workservernq // Multiple itemsservernqservernq // Also pass arrays here (and update/remove)servernq // Note: needs _id in object(s) to mergeservernq // Note: only pass ID(s)
Client
const Client Collection = const client = 'ws://localhost:3000' // A mingo backed minimongo collectionconst Items = 'items' client
React
More typically, you'll use the nesquirk
React components to manage your subscriptions and retrieve data from minimongo collections.
main.js
// Setup the client connectionconst client = 'ws://localhost:3000'client // The Provider allows you to gain access to the client from child components// using the `withClient` helper (see below)ReactDOM
MyComponent.js
const MyComponent = items { // Subscribe - will be auto unsubscribed on componentWillUnmount // Hooks the Items collection up to the '/items' subscription const handle = this // Fetch any data from your collections return items: Itemsall loading: !handle } MyComponent)
Items.js