falcor-async

Call falcor methods before a falcor model is created

Usage no npm install needed!

<script type="module">
  import falcorAsync from 'https://cdn.skypack.dev/falcor-async';
</script>

README

falcor-async Build Status

Call falcor methods before a falcor model is created

Install

$ npm install --save falcor-async

Usage

var FalcorAsync = require('falcor-async')

var model = FalcorAsync(function getModel (callback) {
  // wait until auth is done, and then...
  callback(null, new require('falcor').Model({
    //..options
  })
})

model.get(['foo', 'bar'], ['baz', 'bang'], function (error, data) {
  // methods will be queued until the model is actually loaded
})

API

FalcorAsync(function getModel) -> asyncModel

getModel

Required Type: function

A function which takes a callback. Call the callback with (error, falcorModel).

asyncModel

Returned from FalcorAsync constructor. Has methods get, set, call, invalidate, getValue, onPathChange.

All of these take the normal arguments, with one exception: they don't return promises, instead they accept an additional (error, data) callback at the end.

License

MIT © Andrew Joslin