MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / main

Function main

examples/context/src/parameterized-decoration.ts:43–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41}
42
43export async function main() {
44 const ctx = new Context();
45
46 ctx.bind('name1').to('John');
47 ctx.bind('name2').to('Jane');
48
49 const class1 = createClassWithDecoration('name1', {tags: {prefix: '1'}});
50 const binding1 = createBindingFromClass(class1, {key: 'greeter1'});
51 ctx.add(binding1);
52 console.log('1:', binding1.tagMap);
53
54 const class2 = createClassWithDecoration('name2', {tags: {prefix: '2'}});
55 const binding2 = createBindingFromClass(class2, {key: 'greeter2'});
56 ctx.add(binding2);
57 console.log('2:', binding2.tagMap);
58
59 const greeting1 = await ctx.get<Greeter>('greeter1');
60 console.log('1: %s', greeting1.hello());
61
62 const greeting2 = await ctx.get<Greeter>('greeter2');
63 console.log('2: %s', greeting2.hello());
64}
65
66if (require.main === module) {
67 main().catch(err => {

Callers 1

Calls 7

bindMethod · 0.95
addMethod · 0.95
createBindingFromClassFunction · 0.90
toMethod · 0.80
logMethod · 0.65
helloMethod · 0.65

Tested by

no test coverage detected