import { bindTo } from '@marblejs/core';
bindTo :: ContextToken -> ContextDependency -> BoundDependency
Bind context token to basic types (eg. object):
import { reader, bindTo, createServer, createContextToken } from '@marblejs/core';
const config: Config = { /* ... */ };
const configReader = reader.map(() => config);
const Token = createContextToken<Config>();
// ----------------
createServer({
// ...
dependencies: [
bindTo(Token)(configReader),
],
});
import { reader, bindTo, createServer, createContextToken } from '@marblejs/core';
const fooReader = reader.map(ctx => {
const dependency = context.get(...);
// ...
};
const Token = createContextToken<Foo>();
// ----------------
createServer({
// ...
dependencies: [
bindTo(Token)(fooReader);
],
});