muteEvent
Suppresses the service event for the current call by setting context.event to null. Feathers emits the standard created/updated/patched/removed event (the value of context.event) after the method runs; setting it to null prevents that emission so real-time subscribers and channels are not notified.
Useful for seeding, migrations and internal syncs that should not trigger downstream listeners. Works as a before, after or around hook.
ts
import { } from 'feathers-utils/hooks';Example
ts
import { muteEvent } from 'feathers-utils/hooks'
import { isProvider } from 'feathers-utils/predicates'
app.service('users').hooks({
before: {
all: [muteEvent()], // mute every call
create: [muteEvent({ when: isProvider('server') })], // only server calls
}
})Type declaration
Show Type Declarations
ts
export type MuteEventOptions<H extends HookContext = HookContext> = {
/**
* Only mute when this is truthy. Can be a boolean or a predicate that
* receives the `HookContext`. Defaults to always muting.
*
* @example isProvider('server')
*/
when?: boolean | PredicateFn<H>
}
/**
* Suppresses the service event for the current call by setting `context.event`
* to `null`. Feathers emits the standard `created`/`updated`/`patched`/`removed`
* event (the value of `context.event`) after the method runs; setting it to
* `null` prevents that emission so real-time subscribers and channels are not
* notified.
*
* Useful for seeding, migrations and internal syncs that should not trigger
* downstream listeners. Works as a `before`, `after` or `around` hook.
*
* @example
* ```ts
*
*
*
* app.service('users').hooks({
* before: {
* all: [muteEvent()], // mute every call
* create: [muteEvent({ when: isProvider('server') })], // only server calls
* }
* })
* ```
*
* @see https://utils.feathersjs.com/hooks/mute-event.html
*/
export declare const muteEvent: <H extends HookContext = HookContext>(
options?: MuteEventOptions<H>,
) => (context: H, next?: NextFunction) => Promise<void>| Argument | Type | Description |
|---|---|---|
| options | MuteEventOptions<H> |
| type | methods | multi |
|---|---|---|
| before, after, around | all | yes |
