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

feat(takeWhile): add inclusive option to the operator which causes it to emit the final value #4115

Merged
merged 1 commit into from Jan 30, 2019

Conversation

idosela
Copy link
Contributor

@idosela idosela commented Sep 7, 2018

Description:
By default, the value that causes the predicate to return false is not emitted.

This change adds an inclusive option which changes the behavior of the operator to include the final value which made the predicate return false.
Typical use case: Polling an API until the response contains a certain value, and then doing something with the response.

Related issue: #4000

@idosela idosela changed the title feat(takeWhile): add an inclusive option to the operator which causes to emit final value feat(takeWhile): add inclusive option to the operator which causes it to emit the final value Sep 7, 2018
@ci-reporter
Copy link

ci-reporter bot commented Sep 10, 2018

The build is failing

✨ Good work on this PR so far! ✨ Unfortunately, the Travis CI build is failing as of cc38746. Here's the output:

npm test
> @reactivex/rxjs@6.3.2 test /home/travis/build/ReactiveX/rxjs
> cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha --opts spec/support/default.opts "spec/**/*-spec.ts"


/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:250
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
spec/operators/takeWhile-spec.ts(81,30): error TS2554: Expected 1 arguments, but got 2.

    at createTSError (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:250:12)
    at getOutput (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:358:40)
    at Object.compile (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:545:11)
    at Module.m._compile (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:430:43)
    at Module._extensions..js (module.js:664:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:433:12)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at /home/travis/build/ReactiveX/rxjs/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/home/travis/build/ReactiveX/rxjs/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/home/travis/build/ReactiveX/rxjs/node_modules/mocha/lib/mocha.js:536:10)
    at Object.<anonymous> (/home/travis/build/ReactiveX/rxjs/node_modules/mocha/bin/_mocha:582:18)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

I'm sure you can fix it! If you need help, don't hesitate to ask a maintainer of the project!


Failed build for 0a9291a
npm test
> @reactivex/rxjs@6.3.2 test /home/travis/build/ReactiveX/rxjs
> cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha --opts spec/support/default.opts "spec/**/*-spec.ts"


/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:250
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
spec/operators/takeWhile-spec.ts(81,30): error TS2554: Expected 1 arguments, but got 2.

    at createTSError (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:250:12)
    at getOutput (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:358:40)
    at Object.compile (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:545:11)
    at Module.m._compile (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:430:43)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/home/travis/build/ReactiveX/rxjs/node_modules/ts-node/src/index.ts:433:12)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at /home/travis/build/ReactiveX/rxjs/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/home/travis/build/ReactiveX/rxjs/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/home/travis/build/ReactiveX/rxjs/node_modules/mocha/lib/mocha.js:536:10)
    at Object.<anonymous> (/home/travis/build/ReactiveX/rxjs/node_modules/mocha/bin/_mocha:582:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

This comment was automagically generated by ci-reporter. If you see a problem, open an issue here.

@idosela
Copy link
Contributor Author

idosela commented Sep 10, 2018

@benlesh I keep getting this error:
https://travis-ci.org/ReactiveX/rxjs/jobs/426812416

As far as I can tell I updated all of the required files, and all test are passing when I run them on my machine. I'm probably missing something super-obvious, but I can't figure it out. Any help would be appreciated.

compat/operator/takeWhile.ts Outdated Show resolved Hide resolved
@timdeschryver
Copy link
Contributor

I think these changes should also be added to the dtslint test specs, @cartant ?

@cartant
Copy link
Collaborator

cartant commented Sep 20, 2018

@timdeschryver Yes, it will need dtslint tests. However, ATM, I'm more concerned with the changes merged in #4085 seeming to have been undone. The signature that accepts user-defined type guard appears to have been lost.

@coveralls
Copy link

coveralls commented Sep 20, 2018

Coverage Status

Coverage increased (+0.003%) to 96.97% when pulling f7b3d7d on idosela:take-while-inclusive into 6a2b524 on ReactiveX:master.

@idosela
Copy link
Contributor Author

idosela commented Sep 26, 2018

@cartant I've made the required fixes. Can you please take a look and let me know if there are any other issues I need to address?

src/internal/operators/takeWhile.ts Outdated Show resolved Hide resolved
…es to emit final value

By default, the value that causes the predicate to return `false` is not emitted.

This change adds an `inclusive` option which changes the behavior of the operator to include the final value which made the predicate return `false`.
Typical use case: Polling an API until the response contains a certain value, and then doing something with the response.
@idosela
Copy link
Contributor Author

idosela commented Oct 10, 2018

@cartant Can you please take another look and let me know if there is anything else I need to fix?

@cartant
Copy link
Collaborator

cartant commented Oct 10, 2018

@idosela Sure. I'll look at it again, later today. Sorry for forgetting about it.

Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@idosela
Copy link
Contributor Author

idosela commented Nov 5, 2018

@benlesh @cartant The PR has been approved for a while. When can I expect it to be merged into master?

@felixfbecker
Copy link
Contributor

In need of this too :)

@benlesh benlesh merged commit 6e7f407 into ReactiveX:master Jan 30, 2019
@benlesh
Copy link
Member

benlesh commented Jan 30, 2019

Thanks, @idosela!

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

Successfully merging this pull request may close these issues.

None yet

6 participants