UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

81 lines (41 loc) 1.39 kB
--- lang: en title: 'API docs: context.context.once' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context permalink: /doc/en/lb4/apidocs.context.context.once.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Context](./context.context.md) &gt; [once](./context.context.once.md) ## Context.once() method The "bind" event is emitted when a new binding is added to the context. The "unbind" event is emitted when an existing binding is removed. **Signature:** ```typescript once(eventName: 'bind' | 'unbind', listener: ContextEventListener): this; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> eventName </td><td markdown="1"> 'bind' \| 'unbind' </td><td markdown="1"> The name of the event - always `bind` or `unbind`<!-- -->. </td></tr> <tr><td markdown="1"> listener </td><td markdown="1"> [ContextEventListener](./context.contexteventlistener.md) </td><td markdown="1"> The listener function to call when the event is emitted. </td></tr> </tbody></table> **Returns:** this