Skip to content

Using RXJS 5.5 pipe function : document.createElement is not a function #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RoyiNamir opened this issue Feb 15, 2018 · 1 comment
Closed

Comments

@RoyiNamir
Copy link

Using "rxjs": "~5.5.2", :

I have pipeable/lettable operators as fields :

hideIndicator = tap(x => this._loadingIndicator.hide());
log = tap(x => ...);
catchError = catchError(error =>....);

Later on I do this :

public post<T>(url: string, params: HttpParams)
        {
            this._loadingIndicator.show();
            return this.http.post<T>(urlJoin(this.actionUrl, url), {params})
                                    .pipe(this.hideIndicator, this.catchError);        //<--- notice pipe  as  operator
        }

This ^ code works fine. But I also have GET/DELETE/PUT commands so I don't want to reapeat :

.pipe(this.hideIndicator, this.catchError);.

So it's possible to declare an aggregte method like :

image

notice that now pipe should be imported. so let's do it :

image

And :

image

But I get an error :

System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:
System.err:
System.err: TypeError: document.createElement is not a function
System.err: File: "<unknown>, line: 1, column: 265
System.err:
System.err: StackTrace:
System.err:     Frame: function:'ImmediateDefinition.canUseReadyStateChange', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/util/Immediate.js', line: 56, column: 69
System.err:     Frame: function:'ImmediateDefinition', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/util/Immediate.js', line: 30, column: 27
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/util/Immediate.js', line: 208, column: 21
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/scheduler/AsapAction.js', line: 7, column: 19
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/scheduler/asap.js', line: 2, column: 20
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/observable/SubscribeOnObservable.js', line: 8, column: 14
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/operators/subscribeOn.js', line: 2, column: 31
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/operator/subscribeOn.js', line: 2, column: 21
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/add/operator/subscribeOn.js', line: 3, column: 21
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/tns_modules/rxjs/Rx.js', line: 121, column: 1
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/core/services/http.service.js', line: 18, column: 14
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/core/services/index.js', line: 9, column: 24
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/core/helpers/rps-error-handler.js', line: 13, column: 20
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/core/helpers/index.js', line: 6, column: 10
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/core/core.module.js', line: 19, column: 19
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/app.module.js', line: 14, column: 23
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.davidshield.dsapp1/files/app/main.js', line: 5, column: 22
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:
System.err:     at com.tns.Runtime.runModule(Native Method)
System.err:     at com.tns.Runtime.runModule(Runtime.java:530)
System.err:     at com.tns.Runtime.run(Runtime.java:522)
System.err:     at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
System.err:     ... 8 more
@NickIliev
Copy link

NickIliev commented Feb 15, 2018

@RoyiNamir it seems that you are hitting this issue where any import from rxjs/Rx will actually import the whole library including the DOM-related stuff.

Remove this line

import { Observable, pipe} from "rxjs/Rx";

and try the following:

import { Observable } from "rxjs/Observable";
import { pipe } from 'rxjs/util/pipe';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants