@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 2.25 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/core/base/rxjs-lifetime-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,qBAAa,mBAAoB,YAAW,UAAU;IAElD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA0B;IAE/C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAsB;IAEtC;;OAEG;IACI,gBAAgB,CAAC,GAAG,aAAa,EAAE,gBAAgB,EAAE;IAM5D;;OAEG;IACI,WAAW,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;IAM9C;;;OAGG;IACI,OAAO,IAAI,IAAI;CAYzB","file":"rxjs-lifetime-manager.d.ts","sourcesContent":["import { Subject, SubscriptionLike } from 'rxjs';\r\nimport { Disposable } from '../data/disposable';\r\n\r\n/**\r\n * Helper class for managing rxjs objects that exist for the lifetime of their consumer.\r\n */\r\nexport class RxjsLifetimeManager implements Disposable {\r\n\r\n /**\r\n * Container for active subscriptions that should be cleaned up in the OnDestroy call.\r\n */\r\n private subscriptions: SubscriptionLike[] = [];\r\n\r\n /**\r\n * Container for active subscriptions that should be cleaned up in the OnDestroy call.\r\n */\r\n private subjects: Subject<any>[] = [];\r\n\r\n /**\r\n * Adds rxjs subscriptions to this lifetime manager\r\n */\r\n public addSubscriptions(...subscriptions: SubscriptionLike[]) {\r\n subscriptions.forEach(subscription => {\r\n this.subscriptions.push(subscription);\r\n });\r\n }\r\n\r\n /**\r\n * Adds subjects to this lifetime manager\r\n */\r\n public addSubjects(...subjects: Subject<any>[]) {\r\n subjects.forEach(subject => {\r\n this.subjects.push(subject);\r\n });\r\n }\r\n\r\n /**\r\n * Disposes this instance freeing any resources consumed by it.\r\n * Unsubscribes all subscriptions and completes all subjects.\r\n */\r\n public dispose(): void {\r\n this.subjects.forEach((subject) => {\r\n if (subject && !subject.closed) {\r\n subject.complete();\r\n }\r\n });\r\n this.subscriptions.forEach((subscription) => {\r\n if (subscription && !subscription.closed) {\r\n subscription.unsubscribe();\r\n }\r\n });\r\n }\r\n}\r\n"]}