How to use the devextreme/core/utils/ajax.inject 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 / src / core / transfer-state.ts View on Github external
constructor(private state: TransferState, @Inject(PLATFORM_ID) private platformId: any) {
        let that = this;

        ajax.inject({
            sendRequest: function(...args) {
                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) {