Context API

An object that contains instances of all types within Marty.registry at the point that Marty.createContext() was called. Needed for isomorphic applications.

fetch(callback, options)

Function for tracking all fetches that occur against the context for the duration of the callback. It will invoke the callback and then return a promise which will resolve once all fetches that started within the callback are either done or have failed. Setting timeout within the options configures how long you should wait for a fetch before giving up (Default 1000ms). The promise resolves with diagnostics about the fetches that occurred.

var context = Marty.createContext();

context.fetch(function () {
}, { timeout: 500 }).then(function (diagnostics) {
    console.log('Fetch diagnostics', diagnostics);


Given an instance of a type, resolve the instance for the context.


Get all instances of the given type within the context.


Disposes of all instances of instances.