Skip to content
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

this.project is not a function #2688

Closed
haf opened this issue Jun 21, 2017 · 6 comments
Closed

this.project is not a function #2688

haf opened this issue Jun 21, 2017 · 6 comments

Comments

@haf
Copy link

haf commented Jun 21, 2017

RxJS version: 5.4.0

Code to reproduce:

import { Observable } from 'rxjs/Rx';
const SEND_RESET = "sr";
function successOf(x) { return `${x}_SUCCESS` }
const WaitUntilRedirect = 10;
export function resetRedirectAfterSend(action$: Observable) {
  return action$.ofType(successOf(SEND_RESET)).concatMap(
    Observable
      .range(0, WaitUntilRedirect)
      .delay(
        Observable.timer(1000),
        x => Observable.timer(x * 1000))
      .timeInterval()
      .map(x => setUntilRedirect(WaitUntilRedirect - x.interval * x.value))
      .concatMap(action => push({
        pathname: '/accounts/login',
        query: {
          scent: 'forgot'
        }
      }))
  );
}

Expected behavior:
No crash

Actual behavior:

VM224378:242 Uncaught TypeError: this.project is not a function
    at MergeMapSubscriber._tryNext (eval at ./node_modules/rxjs/operator/mergeMap.js (app.js:9085), <anonymous>:120:27)
    at MergeMapSubscriber._next (eval at ./node_modules/rxjs/operator/mergeMap.js (app.js:9085), <anonymous>:110:18)
    at MergeMapSubscriber.Subscriber.next (eval at ./node_modules/rxjs/Subscriber.js (app.js:7269), <anonymous>:89:18)
    at FilterSubscriber._next (eval at ./node_modules/rxjs/operator/filter.js (app.js:8957), <anonymous>:88:30)
    at FilterSubscriber.Subscriber.next (eval at ./node_modules/rxjs/Subscriber.js (app.js:7269), <anonymous>:89:18)
    at Subject.next (eval at ./node_modules/rxjs/Subject.js (app.js:7253), <anonymous>:55:25)
    at eval (eval at ./node_modules/redux-observable/lib/es/createEpicMiddleware.js (app.js:7078), <anonymous>:69:16)
    at eval (eval at ./app/components/logging/mixpanel.js (app.js:713), <anonymous>:157:16)
    at eval (eval at ./node_modules/react-router-redux/es/middleware.js (app.js:6680), <anonym

Additional information:

@kwonoj
Copy link
Member

kwonoj commented Jun 21, 2017

.concatMap(
    Observable
      .range(0, WaitUntilRedirect)

->
concatMap(project: (value: T, index: number) => ObservableInput<I>) (https://github.com/ReactiveX/rxjs/blob/master/src/operator/concatMap.ts#L68)

@kwonoj kwonoj closed this as completed Jun 21, 2017
@haf
Copy link
Author

haf commented Jun 21, 2017

You're right. What threw me off is the error message; while I did not properly use the functions, it should not crash internally like this.

@kwonoj
Copy link
Member

kwonoj commented Jun 21, 2017

it's quite similar cases to #2144 (comment). Nature of javascript is dynamic and you can provide / call nearly every possible way, in most cases we can't prevent all cases in runtime check. That's reason we're providing TS definition as documented api interface - even user of javascript can refer those interfaces.

@haf
Copy link
Author

haf commented Jun 22, 2017

@kwonoj What's wrong with the code you linked? Your docs state I can supply an observable to concat map (third example here https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/concatmap.md#rxobservableprototypeconcatmapselector-resultselector-thisarg)

source.concatMap(Rx.Observable.of(1,2,3));
source.concatMap(Promise.resolve(42));
source.concatMap([1,2,3]);

@kwonoj
Copy link
Member

kwonoj commented Jun 22, 2017

document you referred is rxjs4, 5 has breaking changes and not compatible.

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants