Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Mar 12, 2020
1 parent 5bc121f commit 9791a5c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-events",
"version": "1.7.4",
"version": "1.8.0",
"description": "Lightweight, strongly-typed events, with monitored subscriptions.",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const pp = new Private<EventConsumer, SubEvent<any>>();
* 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.
* }
Expand Down
13 changes: 11 additions & 2 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,18 @@ export class SubEvent<T = unknown> {
}

/**
* Returns a new [[EventConsumer]] for the event, which removes methods [[emit]] and [[cancelAll]].
* Returns a new [[EventConsumer]] for the event, which physically hides methods [[emit]] and [[cancelAll]].
*
* This method simplifies creation of a receive-only event object.
* This method simplifies creation of a receive-only event object representation.
*
* ```ts
* 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);
* ```
*/
public toConsumer<E extends SubEvent<T>>(): EventConsumer<T, E> {
return new EventConsumer(this);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/private.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Implements proper private properties.
*
* @hidden
*/
export class Private<K extends object, V> {

Expand Down
2 changes: 1 addition & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "SUB-EVENTS v1.7",
"name": "SUB-EVENTS v1.8",
"readme": "README.md",
"mode": "file",
"out": "docs",
Expand Down

0 comments on commit 9791a5c

Please sign in to comment.