How to use the devextreme/core/utils/deferred.Deferred function in devextreme

To help you get started, we’ve selected a few devextreme 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 DevExpress / devextreme-angular / tests / src / server / ssr-ajax.spec.ts View on Github external
callBase: function() {
        let d = new def.Deferred();
        d.resolve('test', 'success');

        return d.promise();
    }
};
github DevExpress / devextreme-angular / src / core / transfer-state.ts View on Github external
let key = makeStateKey(that.generateKey(args)),
                    cachedData = that.state.get(key, null as any);

                if (isPlatformServer(that.platformId)) {
                    let result = this.callBase.apply(this, args);
                    result.always((data, status) => {
                        let dataForCache = {
                            data: data,
                            status: status
                        };
                        that.state.set(key, dataForCache as any);
                    });
                    return result;
                } else {
                    if (cachedData) {
                        let d = new deferred.Deferred();
                        d.resolve(cachedData.data, cachedData.status);
                        that.state.set(key, null as any);

                        return d.promise();
                    }
                    return this.callBase.apply(this, args);
                }
            }
        });