From d1450cdc4144516cbaa9914d0b08acf5c854060c Mon Sep 17 00:00:00 2001 From: Eliran Pe'er Date: Fri, 16 Jun 2017 13:18:15 +0300 Subject: [PATCH] Adding fromEventOnce(eventName) method to the socket service, to support one-time events and async/await operations --- socket-io.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/socket-io.service.ts b/socket-io.service.ts index bcfa713..c8960c1 100644 --- a/socket-io.service.ts +++ b/socket-io.service.ts @@ -58,5 +58,9 @@ export class WrappedSocket { }; }).share(); } - + + /* Creates a Promise for a one-time event */ + fromEventOnce(eventName: string): Promise { + return new Promise(resolve => this.once(eventName, resolve)); + } } \ No newline at end of file