OperationContext
Class: OperationContext<T, U>
OperationContext is used when call to an operation
Extends
EventEmitter
Type parameters
• T = any
type of input for this context
• U = any
type of output for this context
Properties
_body
protected_body:string
Output
Source
packages/core/src/utils/context.ts:87
_promises
_promises:
Promise<any>[]
Contain all registered promises to this context
Source
packages/core/src/utils/context.ts:98
_sanitized
protected_sanitized:any
Contain the sanitized request body if computed
Source
packages/core/src/utils/context.ts:82
_stream
_stream:
Writable
Output stream
Source
packages/core/src/utils/context.ts:120
_webda
protected_webda:Core<CoreEvents>
Contain emitting Core
Source
packages/core/src/utils/context.ts:70
extensions
protectedextensions:Object
Allow extensions
Index signature
[key: string]: any
Source
packages/core/src/utils/context.ts:78
session
protectedsession:Session
Session
Source
packages/core/src/utils/context.ts:74
__globalContext
staticprotected__globalContext:OperationContext<any,any>
Source
packages/core/src/utils/context.ts:65
captureRejectionSymbol
staticreadonlycaptureRejectionSymbol: typeofcaptureRejectionSymbol
Inherited from
EventEmitter.captureRejectionSymbol
Source
packages/core/node_modules/@types/node/events.d.ts:328
captureRejections
staticcaptureRejections:boolean
Sets or gets the default captureRejection value for all emitters.
Inherited from
EventEmitter.captureRejections
Source
packages/core/node_modules/@types/node/events.d.ts:333
defaultMaxListeners
staticdefaultMaxListeners:number
Inherited from
EventEmitter.defaultMaxListeners
Source
packages/core/node_modules/@types/node/events.d.ts:334
errorMonitor
staticreadonlyerrorMonitor: typeoferrorMonitor
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error' listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error' event is emitted, therefore the process will still crash if no
regular 'error' listener is installed.
Inherited from
EventEmitter.errorMonitor
Source
packages/core/node_modules/@types/node/events.d.ts:327
Methods
addAsyncRequest()
addAsyncRequest(
promise):void
Register a promise with the context
Parameters
• promise: any
Returns
void
Source
packages/core/src/utils/context.ts:167
addListener()
addListener(
eventName,listener):this
Alias for emitter.on(eventName, listener).
Parameters
• eventName: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
EventEmitter.addListener
Since
v0.1.26
Source
packages/core/node_modules/@types/node/events.d.ts:354
createStream()
createStream():
void
Create a buffer stream
Returns
void
Source
packages/core/src/utils/context.ts:296
emit()
emit(
eventName, ...args):boolean
Synchronously calls each of the listeners registered for the event namedeventName, in the order they were registered, passing the supplied arguments
to each.
Returns true if the event had listeners, false otherwise.
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
Parameters
• eventName: string | symbol
• ...args: any[]
Returns
boolean
Inherited from
EventEmitter.emit
Since
v0.1.26
Source
packages/core/node_modules/@types/node/events.d.ts:610
end()
end():
Promise<void>
Ensure the whole execution is finished
Returns
Promise<void>
Source
packages/core/src/utils/context.ts:192
eventNames()
eventNames(): (
string|symbol)[]
Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbols.
const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
Returns
(string | symbol)[]
Inherited from
EventEmitter.eventNames
Since
v6.0.0
Source
packages/core/node_modules/@types/node/events.d.ts:669
getCurrentUser()
getCurrentUser<
K>(refresh):Promise<K>
Get the current user from session
Type parameters
• K extends User
Parameters
• refresh: boolean= false
Returns
Promise<K>
Source
packages/core/src/utils/context.ts:361
getCurrentUserId()
getCurrentUserId():
string
Get the current user id from session