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

Method unbind

packages/context/src/context.ts:388–399  ·  view source on GitHub ↗

* Unbind a binding from the context. No parent contexts will be checked. * * @remarks * If you need to unbind a binding owned by a parent context, use the code * below: * * ```ts * const ownerCtx = ctx.getOwnerContext(key); * return ownerCtx != null && ownerCtx.unbind(key);

(key: BindingAddress)

Source from the content-addressed store, hash-verified

386 * @returns true if the binding key is found and removed from this context
387 */
388 unbind(key: BindingAddress): boolean {
389 this.debug('Unbind %s', key);
390 key = BindingKey.validate(key);
391 const binding = this.registry.get(key);
392 // If not found, return `false`
393 if (binding == null) return false;
394 if (binding?.isLocked)
395 throw new Error(`Cannot unbind key "${key}" of a locked binding`);
396 this.registry.delete(key);
397 this.emitEvent('unbind', {binding, context: this, type: 'unbind'});
398 return true;
399 }
400
401 /**
402 * Add a context event observer to the context

Calls 5

debugMethod · 0.95
emitEventMethod · 0.95
validateMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected