-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add defer operator #330
base: main
Are you sure you want to change the base?
Add defer operator #330
Conversation
}); | ||
|
||
return merge([ | ||
calledAfterCondition, |
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.
if condition is already true then call event immediately
return merge([ | ||
calledAfterCondition, | ||
combineEvents({ | ||
events: [calledBeforeCondition, condition.updates.filter({ fn: Boolean })], |
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.
if condition is not true yet then defer event call until condition became true
calledAfterCondition, | ||
combineEvents({ | ||
events: [calledBeforeCondition, condition.updates.filter({ fn: Boolean })], | ||
reset: condition.updates.filter({ fn: (value) => !value }), |
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.
if condition became true and then false we should reset combine events since event call should be deferred until condition will be true again
filter: not(condition), | ||
}); | ||
|
||
return merge([ |
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.
there could be 4 cases:
- Event called, condition is true --> call event
- Event called, condition is false --> wait until condition will be true and call event
- Condition became true, event is not called yet --> wait until event is called
- Condition became false, event is not called yet --> reset the state and wait both for event and condition to become true
IMPORTANT: if clock will be called more than 1 time only the last event will be deferred and called. Other events will be ignored
My suggestion is to write test(s) P.S. yes I know that defer is a common practice but still applicable example will be very much appreciated |
Added default pull request template to help making new operator |
Description
#329
(Why we should add this method?)
Checklist for a new method
src
directory inparam-case
src/method-name/index.ts
in ESModules export incamelCase
named exportsrc/method-name/method-name.test.ts
src/method-name/method-name.fork.test.ts
test-typings/method-name.ts
// @ts-expect-error
to mark expected type errorimport { expectType } from 'tsd'
to check expected return typesrc/method-name/readme.md
Patronum/MethodName
Motivation
,Formulae
,Arguments
andReturn
sections for each overloadExample
section for each overloadsrc/method-name/readme.md
title
. Make sure it uses camelCase syntax just like the method itselfslug
. Use param-case to write it. In most cases it will be just liketitle
desription
with one short sentence describing what method useful forgroup
. To categorize method on/operators
page. Full list of available groups, you can see in documentation/src/content/config.ts