-
Notifications
You must be signed in to change notification settings - Fork 3k
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(timeout): One timeout to rule them all #5602
Conversation
Should resolve the concerns here: #4537 |
I'm game to change the name of So the |
A couple of API points. This seems like a kitchen sink function (not a bad thing), in which case we may want to allow more flexibility. What do you think about replacing Also the Taking your examples above it would turn into: source$.pipe(
timeout({
// First item must happen by '10/22/2021, after that every 1 second
timeAllowed: info => info.seen === 0 ? new Date('10/22/2021') : 1000
timeoutReason: info => `Timeout out after ${info.seen} values. Reason: 'Too slow!'. Last value: ${info.lastValue}`,
}
})
)
source$.pipe(
timeout({
// If the first value does not arrive within 4 seconds, timeout.
// After that, values may arrive after any delay
timeAllowed: info => info.seen === 0 ? 4000 : Infinity
}).pipe(
catchError(err =>
of(`Timeout out after ${err.info.seen} values. Reason:''Too slow!''. Last value: ${error.info.lastValue}`);
)
),
) I know I kind of have the examples backwards where the first example throws and the second doesn't but I think the point still gets across. Thoughts? |
@kolodny I've wondered if the timeout({
first: 5000,
with: () => { throw new CustomError('meta stuff here'); }
}) However this means that As far as the names go, I was trying to be minimalist, but maybe they missed the mark, I'm not sure. I do know I'm not a fan of the word |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of nits and some opinions. Still thinking about the meta
business.
…eactiveX#5594) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.15...4.17.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Adds configuration argument pattern - Fixes issue where `timeout` and `timeoutWith` would always timeout when provided a Date as a due time, even if the source emitted a value before then. - Adds ability to configure timeout to have a different `first` timeout check and subsequent `each` timeout checks - Adds ability to timeout if _just_ the first value does not arrive after a specified number of milliseconds - Adds additional information to `TimeoutError`s thrown by bare `timeout` calls. - Adds `with` parameter to `timeout` operator's configuration, such that now `timeout` can be used in exactly the same ways as `timeoutWith` and more. The `with` parameter is a function that provides information about the timeout and expects an `ObservableInput` to switch to in response to a timeout. - Deprecates `timeoutWith`. - Updates tests to use run mode. - Adds additional tests to `timeout` to cover more aspects of the configuration possiblities. - Improves type signatures for `timeout` and `timeoutWith`.
e81bfb1
to
167ce61
Compare
timeout
andtimeoutWith
would always timeout when provided a Date as a due time, even if the source emitted a value before then.first
timeout check and subsequenteach
timeout checksTimeoutError
s thrown by baretimeout
calls.with
parameter totimeout
operator's configuration, such that nowtimeout
can be used in exactly the same ways astimeoutWith
and more. Thewith
parameter is a function that provides information about the timeout and expects anObservableInput
to switch to in response to a timeout.timeoutWith
.timeout
to cover more aspects of the configuration possiblities.timeout
andtimeoutWith
.Basic New Usage Patterns
IN ADDITION to the existing functionality of
timeout
, thetimeout
operator now can accept a single configuration object that allows better control over timeouts.TODO: