Class Constructor.
-Event object to be encapsulated.
-Forwards into SubEvent.count of the contained event.
-Forwards into SubEvent.maxSubs of the contained event.
-Forwards into SubEvent.getStat of the contained event.
-Forwards into SubEvent.once of the contained event.
-Forwards into SubEvent.subscribe of the contained event.
-Forwards into SubEvent.toPromise of the contained event.
-Generated using TypeDoc
-Encapsulates an event object, in order to hide its methods SubEvent.emit and SubEvent.cancelAll, +so the event consumer can only receive the event, but cannot emit it, or cancel other subscriptions.
+It is a non-extendable class, with the same signature as SubEvent, minus emit and cancelAll.
+// Example of using EventConsumer inside a component.
import {SubEvent, EventConsumer} from 'sub-events';
class MyComponent {
private event: SubEvent<string> = new SubEvent(); // internal, send-receive event
readonly safeEvent: EventConsumer<string>; // public, receive-only event container
constructor() {
this.safeEvent = new EventConsumer(this.event);
// or even simpler:
// this.safeEvent = this.event.toConsumer();
// clients can only receive data from such "safeEvent",
// they cannot emit data or cancel other subscriptions.
}
}
+
+
+Forwards into SubEvent.count of the contained event.
+Forwards into SubEvent.maxSubs of the contained event.
+Forwards into SubEvent.getStat of the contained event.
+Optional
options: { Optional
minForwards into SubEvent.once of the contained event.
+Optional
options: ISubOptionsForwards into SubEvent.subscribe of the contained event.
+Optional
options: ISubOptionsForwards into SubEvent.toPromise of the contained event.
+Optional
options: { Optional
name?: stringOptional
timeout?: numberConfiguration Options.
-Current number of live subscriptions.
-Maximum number of subscribers that can receive events.
- Default is 0, meaning no limit applies
.
Newer subscriptions outside of the maximum quota will start - receiving events when the older subscriptions get cancelled.
-It can only be set with the constructor.
-Cancels all existing subscriptions for the event.
-This is a convenience method for some special cases, when you want to cancel all subscriptions - for the event at once. Usually, subscribers just call cancel when they want to cancel their - own subscription.
-This method will always offer much better performance than cancelling each subscription individually, - which may become increasingly important when working with a large number of subscribers.
- -Number of subscriptions cancelled.
-Broadcasts data to all subscribers, according to the emit schedule, - which is synchronous by default.
-Data to be sent, according to the template type.
-Event-emitting options.
-The event object itself.
-Retrieves subscriptions statistics, to help with diagnosing subscription leaks.
-For this method to be useful, you need to set option name
when calling subscribe.
See also: Diagnostics
- -Statistics Options:
-minUse: number
- Minimum subscription usage/count to be included into the list of named
- subscriptions. If subscription is used less times, it will be excluded from the named
list.Subscribes to receive just one event, and cancel the subscription immediately.
-You may still want to call cancel on the returned Subscription object, - if you suddenly need to prevent the first event, or to avoid dead once-off - subscriptions that never received their event, and thus were not cancelled.
- -Event notification function, invoked after self-cancelling the subscription.
-Subscription Options.
-Object for cancelling the subscription safely.
-Subscribes to the event.
-When subscription is no longer needed, method cancel should be called on the - returned object, to avoid performance degradation caused by abandoned subscribers.
-Method getStat can help with diagnosing leaked subscriptions.
- -Event notification callback function.
-Subscription Options.
-Object for cancelling the subscription safely.
-Returns a new EventConsumer for the event, which physically hides methods emit and cancelAll.
-This method simplifies creation of a receive-only event object representation.
-const e = new SubEvent<number>(); // full-access, emit-receive event
-
-const c = e.toConsumer(); // the same "e" event, but with receive-only access
-
-// It is equivalent to the full syntax of:
-// const c = new EventConsumer<number>(e);
-
- Creates a new subscription as a promise, to resolve with the next received event value, - and cancel the subscription.
-Examples of where it can be useful include:
-try {
- const nextValue = await myEvent.toPromise({timeout: 1000});
-} catch(e) {
- // Either subscription didn't produce any event after 1 second,
- // or myEvent.cancelAll() was called somewhere.
-}
-
- The returned promise can reject in two cases:
-timeout
), it rejects with Event timed out
error;Event cancelled
error.Note that if you use this method consecutively, you can miss events in between, - because the subscription is auto-cancelled after receiving the first event.
- -Subscription Options:
-name
- for the internal subscription name. See name
in ISubOptions.
- In this context, it is also included within any rejection error.
timeout
- sets timeout in ms (when timeout
>= 0), to auto-reject with
- Event timed out
error.
Generated using TypeDoc
-Core class, implementing event subscription + emitting the event.
+Current number of live subscriptions.
+Maximum number of subscribers that can receive events.
+Default is 0, meaning no limit applies
.
Newer subscriptions outside the maximum quota will start +receiving events when the older subscriptions get cancelled.
+It can only be set with the constructor.
+Cancels all existing subscriptions for the event.
+This is a convenience method for some special cases, when you want to cancel all subscriptions +for the event at once. Usually, subscribers just call cancel when they want to cancel their +own subscription.
+This method will always offer much better performance than cancelling each subscription individually, +which may become increasingly important when working with a large number of subscribers.
+Number of subscriptions cancelled.
+Broadcasts data to all subscribers, according to the emit
schedule,
+which is synchronous by default.
Data to be sent, according to the template type.
+Optional
options: IEmitOptionsEvent-emitting options.
+The event object itself.
+Retrieves subscriptions statistics, to help with diagnosing subscription leaks.
+For this method to be useful, you need to set option name
when calling SubEvent.subscribe.
See also: Diagnostics
+Optional
options: { Statistics Options:
+minUse: number
- Minimum subscription usage/count to be included into the list of named
+subscriptions. If subscription is used fewer times, it will be excluded from the named
list.Optional
minSubscribes to receive just one event, and cancel the subscription immediately.
+You may still want to call Subscription.cancel on the returned object, +if you suddenly need to prevent the first event, or to avoid dead once-off +subscriptions that never received their event, and thus were not cancelled.
+Event notification function, invoked after self-cancelling the subscription.
+Optional
options: ISubOptionsSubscription Options.
+Object for cancelling the subscription safely.
+Subscribes to the event.
+When subscription is no longer needed, method Subscription.cancel should be called on the +returned object, to avoid performance degradation caused by abandoned subscribers.
+Method SubEvent.getStat can help with diagnosing leaked subscriptions.
+Event notification callback function.
+Optional
options: ISubOptionsSubscription Options.
+Object for cancelling the subscription safely.
+Returns a new EventConsumer for the event, which physically hides methods SubEvent.emit and SubEvent.cancelAll.
+This method simplifies creation of a receive-only event object representation.
+const e = new SubEvent<number>(); // full-access, emit-receive event
const c = e.toConsumer(); // the same "e" event, but with receive-only access
// It is equivalent to the full syntax of:
// const c = new EventConsumer<number>(e);
+
+
+Creates a new subscription as a promise, to resolve with the next received event value, +and cancel the subscription.
+Examples of where it can be useful include:
+try {
const nextValue = await myEvent.toPromise({timeout: 1000});
} catch(e) {
// Either subscription didn't produce any event after 1 second,
// or myEvent.cancelAll() was called somewhere.
}
+
+
+The returned promise can reject in two cases:
+timeout
), it rejects with Event timed out
error;Event cancelled
error.Note that if you use this method consecutively, you can miss events in between, +because the subscription is auto-cancelled after receiving the first event.
+Optional
options: { Subscription Options:
+name
- for the internal subscription name. See name
in ISubOptions.
+In this context, it is also included within any rejection error.
timeout
- sets timeout in ms (when timeout
>= 0), to auto-reject with
+Event timed out
error.
Optional
name?: stringOptional
timeout?: numberConfiguration Options.
-Triggered on any change in the number of subscriptions.
-Current number of live subscriptions.
-Maximum number of subscribers that can receive events.
- Default is 0, meaning no limit applies
.
Newer subscriptions outside of the maximum quota will start - receiving events when the older subscriptions get cancelled.
-It can only be set with the constructor.
-Cancels all existing subscriptions for the event.
-It overrides the base implementation, to trigger event onCount - when there was at least one subscription.
- -Number of subscriptions cancelled.
-Broadcasts data to all subscribers, according to the emit schedule, - which is synchronous by default.
-Data to be sent, according to the template type.
-Event-emitting options.
-The event object itself.
-Retrieves subscriptions statistics, to help with diagnosing subscription leaks.
-For this method to be useful, you need to set option name
when calling subscribe.
See also: Diagnostics
- -Statistics Options:
-minUse: number
- Minimum subscription usage/count to be included into the list of named
- subscriptions. If subscription is used less times, it will be excluded from the named
list.Subscribes to receive just one event, and cancel the subscription immediately.
-You may still want to call cancel on the returned Subscription object, - if you suddenly need to prevent the first event, or to avoid dead once-off - subscriptions that never received their event, and thus were not cancelled.
- -Event notification function, invoked after self-cancelling the subscription.
-Subscription Options.
-Object for cancelling the subscription safely.
-Subscribes to the event.
-When subscription is no longer needed, method cancel should be called on the - returned object, to avoid performance degradation caused by abandoned subscribers.
-Method getStat can help with diagnosing leaked subscriptions.
- -Event notification callback function.
-Subscription Options.
-Object for cancelling the subscription safely.
-Returns a new EventConsumer for the event, which physically hides methods emit and cancelAll.
-This method simplifies creation of a receive-only event object representation.
-const e = new SubEvent<number>(); // full-access, emit-receive event
-
-const c = e.toConsumer(); // the same "e" event, but with receive-only access
-
-// It is equivalent to the full syntax of:
-// const c = new EventConsumer<number>(e);
-
- Creates a new subscription as a promise, to resolve with the next received event value, - and cancel the subscription.
-Examples of where it can be useful include:
-try {
- const nextValue = await myEvent.toPromise({timeout: 1000});
-} catch(e) {
- // Either subscription didn't produce any event after 1 second,
- // or myEvent.cancelAll() was called somewhere.
-}
-
- The returned promise can reject in two cases:
-timeout
), it rejects with Event timed out
error;Event cancelled
error.Note that if you use this method consecutively, you can miss events in between, - because the subscription is auto-cancelled after receiving the first event.
- -Subscription Options:
-name
- for the internal subscription name. See name
in ISubOptions.
- In this context, it is also included within any rejection error.
timeout
- sets timeout in ms (when timeout
>= 0), to auto-reject with
- Event timed out
error.
Generated using TypeDoc
-Event constructor.
+Optional
options: ICountOptions<T>Configuration Options.
+Current number of live subscriptions.
+Maximum number of subscribers that can receive events.
+Default is 0, meaning no limit applies
.
Newer subscriptions outside the maximum quota will start +receiving events when the older subscriptions get cancelled.
+It can only be set with the constructor.
+Cancels all existing subscriptions for the event.
+It overrides the base implementation, to trigger event onCount +when there was at least one subscription.
+Number of subscriptions cancelled.
+Broadcasts data to all subscribers, according to the emit
schedule,
+which is synchronous by default.
Data to be sent, according to the template type.
+Optional
options: IEmitOptionsEvent-emitting options.
+The event object itself.
+Retrieves subscriptions statistics, to help with diagnosing subscription leaks.
+For this method to be useful, you need to set option name
when calling SubEvent.subscribe.
See also: Diagnostics
+Optional
options: { Statistics Options:
+minUse: number
- Minimum subscription usage/count to be included into the list of named
+subscriptions. If subscription is used fewer times, it will be excluded from the named
list.Optional
minSubscribes to receive just one event, and cancel the subscription immediately.
+You may still want to call Subscription.cancel on the returned object, +if you suddenly need to prevent the first event, or to avoid dead once-off +subscriptions that never received their event, and thus were not cancelled.
+Event notification function, invoked after self-cancelling the subscription.
+Optional
options: ISubOptionsSubscription Options.
+Object for cancelling the subscription safely.
+Subscribes to the event.
+When subscription is no longer needed, method Subscription.cancel should be called on the +returned object, to avoid performance degradation caused by abandoned subscribers.
+Method SubEvent.getStat can help with diagnosing leaked subscriptions.
+Event notification callback function.
+Optional
options: ISubOptionsSubscription Options.
+Object for cancelling the subscription safely.
+Returns a new EventConsumer for the event, which physically hides methods SubEvent.emit and SubEvent.cancelAll.
+This method simplifies creation of a receive-only event object representation.
+const e = new SubEvent<number>(); // full-access, emit-receive event
const c = e.toConsumer(); // the same "e" event, but with receive-only access
// It is equivalent to the full syntax of:
// const c = new EventConsumer<number>(e);
+
+
+Creates a new subscription as a promise, to resolve with the next received event value, +and cancel the subscription.
+Examples of where it can be useful include:
+try {
const nextValue = await myEvent.toPromise({timeout: 1000});
} catch(e) {
// Either subscription didn't produce any event after 1 second,
// or myEvent.cancelAll() was called somewhere.
}
+
+
+The returned promise can reject in two cases:
+timeout
), it rejects with Event timed out
error;Event cancelled
error.Note that if you use this method consecutively, you can miss events in between, +because the subscription is auto-cancelled after receiving the first event.
+Optional
options: { Subscription Options:
+name
- for the internal subscription name. See name
in ISubOptions.
+In this context, it is also included within any rejection error.
timeout
- sets timeout in ms (when timeout
>= 0), to auto-reject with
+Event timed out
error.
Optional
name?: stringOptional
timeout?: numberRepresents an event subscription, and a safe way to cancel it.
- -Subscription's name
option, if it was set with method subscribe.
Indicates whether the subscription is live / active.
-It can be useful to subscribers when cancelAll is used without their knowledge.
-Cancels the live subscription. The subscriber won't receive any more events.
-It also sets flag live to false
.
true
- subscription has been successfully cancelledfalse
- nothing happened, as subscription wasn't liveGenerated using TypeDoc
-Represents an event subscription, and a safe way to cancel it.
+Optional
Readonly
nameSubscription's name
option, if it was set with method SubEvent.subscribe.
Indicates whether the subscription is live / active.
+It can be useful to subscribers when SubEvent.cancelAll is used without their knowledge.
+Cancels the live subscription. The subscriber won't receive any more events.
+It also sets flag live to false
.
true
- subscription has been successfully cancelledfalse
- nothing happened, as subscription wasn't liveSchedule for emitting / broadcasting data to subscribers, to be used by method emit. - It represents a concurrency strategy for delivering event to subscribers.
-Data broadcast is fully asynchronous: each subscriber will be receiving the event - within its own processor tick (under Node.js), or timer tick (in browsers).
-Subscribers are enumerated after the initial delay.
-Wait for the next processor tick (under Node.js), or timer tick (in browsers), - and then broadcast data to all subscribers synchronously.
-Subscribers are enumerated after the delay.
-Data is sent to all subscribers synchronously / immediately.
-This is the default schedule.
-Generated using TypeDoc
-Schedule for emitting / broadcasting data to subscribers, to be used by method SubEvent.emit. +It represents a concurrency strategy for delivering event to subscribers.
+Data broadcast is fully asynchronous: each subscriber will be receiving the event +within its own processor tick (under Node.js), or timer tick (in browsers).
+Subscribers are enumerated after the initial delay.
+Wait for the next processor tick (under Node.js), or timer tick (in browsers), +and then broadcast data to all subscribers synchronously.
+Subscribers are enumerated after the delay.
+Data is sent to all subscribers synchronously / immediately.
+This is the default schedule.
+Lightweight, strongly-typed events, with monitored subscriptions.
- - -npm i sub-events
-
-
- import {SubEvent} from 'sub-events';
-
-// creating a strongly-typed event:
-const e: SubEvent<string> = new SubEvent();
-
-// triggering the event when needed:
-e.emit('hello');
-
-
- // subscribing to the event:
-const sub = e.subscribe((data: string) => {
- // data = 'hello'
-});
-
-// cancel the subscription when no longer needed:
-sub.cancel();
-
- API: Subscription, subscribe, cancel
- -Class SubEventCount extends SubEvent with event onCount, to observe the number of subscriptions:
-import {SubEventCount, ISubCountChange} from 'sub-events';
-
-// creating a strongly-typed event:
-const e: SubEventCount<string> = new SubEventCount();
-
-e.onCount.subscribe((info: ISubCountChange) => {
- // number of subscriptions has changed;
- // info = {newCount, prevCount}
-});
-
-// any subscription will trigger event onCount:
-const sub = e.subscribe(data => {});
-
-// cancelling a subscription will trigger onCount:
-sub.cancel();
-
- API: SubEventCount, onCount
- -When including directly from HTML, you can access all types under subEvents
namespace:
<script src="./node_modules/sub-events/dist"></script>
-<script>
- const e = new subEvents.SubEvent();
- e.subscribe(data => {
- // data received
- });
-</script>
-
- Note that pre-built script includes only the core library, without the Extras, - which you can bundle yourself as needed.
-Subscription callback function type.
-Generated using TypeDoc
-Lightweight, strongly-typed events, with monitored subscriptions.
+ +npm i sub-events
+
+
+import {SubEvent} from 'sub-events';
// creating a strongly-typed event:
const e: SubEvent<string> = new SubEvent();
// triggering the event when needed:
e.emit('hello');
+
+
+
+// subscribing to the event:
const sub = e.subscribe((data: string) => {
// data = 'hello'
});
// cancel the subscription when no longer needed:
sub.cancel();
+
+
+API: Subscription, subscribe, cancel
+Class SubEventCount extends SubEvent with event onCount, to observe the number of subscriptions:
+import {SubEventCount, ISubCountChange} from 'sub-events';
// creating a strongly-typed event:
const e: SubEventCount<string> = new SubEventCount();
e.onCount.subscribe((info: ISubCountChange) => {
// number of subscriptions has changed;
// info = {newCount, prevCount}
});
// any subscription will trigger event onCount:
const sub = e.subscribe(data => {});
// cancelling a subscription will trigger onCount:
sub.cancel();
+
+
+API: SubEventCount, onCount
+When including directly from HTML, you can access all types under subEvents
namespace:
<script src="./node_modules/sub-events/dist"></script>
<script>
const e = new subEvents.SubEvent();
e.subscribe(data => {
// data received
});
</script>
+
+
+Note that pre-built script includes only the core library, without the Extras, +which you can bundle yourself as needed.
+Constructor options for SubEventCount class.
-Emit options for event onCount.
-Maximum number of subscribers that can receive events.
- Default is 0, meaning no limit applies
.
Newer subscriptions outside of the maximum quota will start - receiving events when the older subscriptions get cancelled.
-Notification about a cancelled subscription.
-(ctx: ISubContext<T>) => void;
-
-
- Notification of a new subscriber being registered.
-(ctx: ISubContext<T>) => void;
-
-
- Generated using TypeDoc
-Constructor options for SubEventCount class.
+Optional
emitEmit options for event SubEventCount.onCount.
+Optional
maxMaximum number of subscribers that can receive events.
+Default is 0, meaning no limit applies
.
Newer subscriptions outside the maximum quota will start +receiving events when the older subscriptions get cancelled.
+Optional
onNotification about a cancelled subscription.
+(ctx: ISubContext<T>) => void;
+
+
+ctx
: ISubContext - Subscription Context.
Optional
onNotification of a new subscriber being registered.
+(ctx: ISubContext<T>) => void;
+
+
+ctx
: ISubContext - Subscription Context.
Options to be used with method emit.
-Callback for catching all unhandled errors from subscribers, - from both synchronous and asynchronous subscription functions.
-(err: any, name?: string) => void;
-
-
- Notification callback of when the last recipient has received the data. - Note that asynchronous subscribers may still be processing the data at this point.
-(count: number) => void;
-
-
- Event-emitting schedule. Default is sync
.
Generated using TypeDoc
-Options to be used with method SubEvent.emit.
+Optional
onCallback for catching all unhandled errors from subscribers, +from both synchronous and asynchronous subscription functions.
+(err: any, name?: string) => void;
+
+
+err
: The error that was thrown or rejected.
Optional
name: stringname
: The subscription name
, if set during SubEvent.subscribe call.
Optional
onNotification callback of when the last recipient has received the data. +Note that asynchronous subscribers may still be processing the data at this point.
+(count: number) => void;
+
+
+count
: Total number of subscribers that have received the data.
Optional
scheduleEvent-emitting schedule. Default is sync
.
Constructor options for SubEvent class.
-Maximum number of subscribers that can receive events.
- Default is 0, meaning no limit applies
.
Newer subscriptions outside of the maximum quota will start - receiving events when the older subscriptions get cancelled.
-Notification about a cancelled subscription.
-(ctx: ISubContext<T>) => void;
-
-
- Notification of a new subscriber being registered.
-(ctx: ISubContext<T>) => void;
-
-
- Generated using TypeDoc
-Constructor options for SubEvent class.
+Optional
maxMaximum number of subscribers that can receive events.
+Default is 0, meaning no limit applies
.
Newer subscriptions outside the maximum quota will start +receiving events when the older subscriptions get cancelled.
+Optional
onNotification about a cancelled subscription.
+(ctx: ISubContext<T>) => void;
+
+
+ctx
: ISubContext - Subscription Context.
Optional
onNotification of a new subscriber being registered.
+(ctx: ISubContext<T>) => void;
+
+
+ctx
: ISubContext - Subscription Context.
Subscription Context Interface, as used with onSubscribe and onCancel - notification options that can be set during SubEvent construction.
-Unknown-type data to let event wrappers persist any - context they need within the event's lifecycle.
-Event object that provides the context.
-Subscription name, if one was specified with method subscribe.
-Generated using TypeDoc
-Subscription Context Interface, as used with IEventOptions.onSubscribe and IEventOptions.onCancel +notification options that can be set during SubEvent construction.
+Optional
dataUnknown-type data to let event wrappers persist any +context they need within the event's lifecycle.
+Readonly
eventEvent object that provides the context.
+Optional
Readonly
nameSubscription name, if one was specified with method SubEvent.subscribe.
+Represents a change in the number of subscriptions, as used with onCount event.
-New number of subscriptions.
-Previous number of subscriptions.
-Generated using TypeDoc
-Represents a change in the number of subscriptions, as used with SubEventCount.onCount event.
+Options that can be passed into method subscribe.
-Unique subscription name. It helps with diagnosing subscription leaks, - via method getStat, and provides additional details during error handling. - The name should help identify place in the code where the subscription was created.
-Subscription-cancel callback, to be notified on subscription explicit - cancel call, or when cancelled implicitly via cancelAll.
-This is mostly for internal usage, and has no protection against - errors, should the handler throw any.
-Calling / this
context for the subscription callback function.
Standard way of passing in context is this way:
-event.subscribe(func.bind(this))
-
- With this option you can also do it this way:
-event.subscribe(func, {thisArg: this})
-
- Generated using TypeDoc
-Options that can be passed into method SubEvent.subscribe.
+Optional
nameUnique subscription name. It helps with diagnosing subscription leaks, +via method SubEvent.getStat, and provides additional details during error handling. +The name should help identify place in the code where the subscription was created.
+Optional
onSubscription-cancel callback, to be notified on subscription explicit +Subscription.cancel call, or when cancelled implicitly via SubEvent.cancelAll.
+This is mostly for internal usage, and has no protection against +errors, should the handler throw any.
+Optional
thisCalling / this
context for the subscription callback function.
Standard way of passing in context is this way:
+event.subscribe(func.bind(this))
+
+
+With this option you can also do it this way:
+event.subscribe(func, {thisArg: this})
+
+
+Subscriptions statistics, as returned by method getStat.
-Map of subscription names to their usage counters. It consists of only
- subscriptions for which option name
was set when calling subscribe.
Total number of unnamed subscriptions.
-Generated using TypeDoc
-Subscriptions statistics, as returned by method SubEvent.getStat.
+Map of subscription names to their usage counters. It consists of only
+subscriptions for which option name
was set when calling SubEvent.subscribe.
Total number of unnamed subscriptions.
+Lightweight, strongly-typed events, with monitored subscriptions.
- - -npm i sub-events
-
-
- import {SubEvent} from 'sub-events';
-
-// creating a strongly-typed event:
-const e: SubEvent<string> = new SubEvent();
-
-// triggering the event when needed:
-e.emit('hello');
-
-
- // subscribing to the event:
-const sub = e.subscribe((data: string) => {
- // data = 'hello'
-});
-
-// cancel the subscription when no longer needed:
-sub.cancel();
-
- API: Subscription, subscribe, cancel
- -Class SubEventCount extends SubEvent with event onCount, to observe the number of subscriptions:
-import {SubEventCount, ISubCountChange} from 'sub-events';
-
-// creating a strongly-typed event:
-const e: SubEventCount<string> = new SubEventCount();
-
-e.onCount.subscribe((info: ISubCountChange) => {
- // number of subscriptions has changed;
- // info = {newCount, prevCount}
-});
-
-// any subscription will trigger event onCount:
-const sub = e.subscribe(data => {});
-
-// cancelling a subscription will trigger onCount:
-sub.cancel();
-
- API: SubEventCount, onCount
- -When including directly from HTML, you can access all types under subEvents
namespace:
<script src="./node_modules/sub-events/dist"></script>
-<script>
- const e = new subEvents.SubEvent();
- e.subscribe(data => {
- // data received
- });
-</script>
-
- Note that pre-built script includes only the core library, without the Extras, - which you can bundle yourself as needed.
-Subscription callback function type.
-Generated using TypeDoc
-
class EventConsumer<T = unknown, E extends SubEvent<T> = SubEvent<T>>
- -Encapsulates an event object, in order to hide its methods emit and cancelAll, so the event - consumer can only receive the event, but cannot emit it, or cancel other subscriptions.
-It is a non-extendable class, with the same signature as SubEvent, minus methods emit and cancelAll.
- -