How to use the alcalzone-shared/deferred-promise.createDeferredPromise function in alcalzone-shared

To help you get started, we’ve selected a few alcalzone-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AlCalzone / node-tradfri-client / test / mocks.ts View on Github external
.callsFake((path: string, method, payload) => {
					// For requests we need to store one-time promises
					requestPromises[path] = createDeferredPromise();
					// in any case, remove the reference after the promise has served its purpose
					requestPromises[path]
						.then(() => delete requestPromises[path])
						.catch(() => delete requestPromises[path])
						;
					return requestPromises[path];
				});
		} else {
github AlCalzone / node-tradfri-client / build / tradfri-client.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            if (this.isObserving(endpoints_1.endpoints.groups))
                return;
            this.observeGroupsPromise = deferred_promise_1.createDeferredPromise();
            // We have a timing problem here, as the observeGatewayPromise might be
            // rejected in the callback and set to null. Therefore return it before
            // starting the observation
            void this.observeResource(endpoints_1.endpoints.groups, (resp) => void this.observeGroups_callback(resp)).catch(e => {
                // pass errors through
                if (!!this.observeGroupsPromise)
                    this.observeGroupsPromise.reject(e);
            });
            return this.observeGroupsPromise;
        });
    }
github AlCalzone / node-tradfri-client / build / tradfri-client.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            if (this.isObserving(endpoints_1.endpoints.devices))
                return;
            this.observeDevicesPromise = deferred_promise_1.createDeferredPromise();
            // We have a timing problem here, as the observeGatewayPromise might be
            // rejected in the callback and set to null. Therefore return it before
            // starting the observation
            void this.observeResource(endpoints_1.endpoints.devices, (resp) => void this.observeDevices_callback(resp)).catch(e => {
                // pass errors through
                if (!!this.observeDevicesPromise)
                    this.observeDevicesPromise.reject(e);
            });
            return this.observeDevicesPromise;
        });
    }
github AlCalzone / node-tradfri-client / build / tradfri-client.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            if (this.isObserving(endpoints_1.endpoints.gateway(endpoints_1.GatewayEndpoints.Details)))
                return;
            this.observeGatewayPromise = deferred_promise_1.createDeferredPromise();
            // We have a timing problem here, as the observeGatewayPromise might be
            // rejected in the callback and set to null. Therefore return it before
            // starting the observation
            void this.observeResource(endpoints_1.endpoints.gateway(endpoints_1.GatewayEndpoints.Details), (resp) => void this.observeGateway_callback(resp)).catch(e => {
                // pass errors through
                if (!!this.observeGatewayPromise)
                    this.observeGatewayPromise.reject(e);
            });
            return this.observeGatewayPromise;
        });
    }
github AlCalzone / node-tradfri-client / build / tradfri-client.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            if (this.isObserving(endpoints_1.endpoints.notifications))
                return;
            this.observeNotificationsPromise = deferred_promise_1.createDeferredPromise();
            // We have a timing problem here, as the observeNotificationsPromise might be
            // rejected in the callback and set to null. Therefore return it before
            // starting the observation
            void this.observeResource(endpoints_1.endpoints.notifications, (resp) => void this.observeNotifications_callback(resp)).catch(e => {
                // pass errors through
                if (!!this.observeNotificationsPromise)
                    this.observeNotificationsPromise.reject(e);
            });
            return this.observeNotificationsPromise;
        });
    }

alcalzone-shared

A set of utilities shared between my projects

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis

Similar packages