Split creation functions from creation functions with Schedulers
See original GitHub issueCurrently we have creation functions like so:
from(obj)
andfrom(obj, scheduler)
range(a, b)
andrange(a, b, scheduler)
- (… and many more)
Problem
Schedulers and scheduling adds a LOT of bloat to bundles and we can’t currently avoid it.
If you look at the implementations of these you’ll see an obvious pattern, especially in the ones I more recently created as “just functions”:
function fromSomething<T>(something: Something<T>, scheduler?: IScheduler) {
if (!scheduler) {
return new Observable(/* a little bit of code */);
} else {
return new Observable<T>(subscriber => {
/* OMG WHAT?!! A HUGE MOUNTAIN OF CODE AND A BUNCH OF TYPES
WE NEED TO IMPORT FOR THIS SO WE CAN DO THINGS
WITH SCHEDULERS, WHICH DON'T GET USED 95% OF THE TIME */
});
}
}
/* MORE STUFF DOWN HERE FOR SCHEDULING SUPPORT */
function dispatch() {
/* you get the idea */
}
Proposal
- Split creation methods into “normal” and “scheduled” flavors:
from
andfromScheduled
,defer
anddeferScheduled
,range
andrangeScheduled
etc.
If we do this, then the majority of RxJS usage (which doesn’t involve schedulers) can avoid pulling in scheduler-related classes and scheduling-related logic.
That would make the above into:
95% use case
function fromSomething<T>(something: Something<T>) {
return new Observable(/* a little bit of code */);
}
and else where
5% use case
function fromSomethingScheduled<T>(something: Something<T>, scheduler: IScheduler) {
return new Observable<T>(subscriber => {
/* OMG WHAT?!! A HUGE MOUNTAIN OF CODE AND A BUNCH OF TYPES
WE NEED TO IMPORT FOR THIS SO WE CAN DO THINGS
WITH SCHEDULERS, WHICH DON'T GET USED 95% OF THE TIME */
});
}
/* MORE STUFF DOWN HERE FOR SCHEDULING SUPPORT */
function dispatch() {
/* you get the idea */
}
Risks
It will be a breaking change for people using schedulers today. Easy to fix, but annoying.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Automatic Assignment Split
If the conditions for an automatic assignment split are met, the system splits the assignment and creates one or more assignments for the...
Read more >Why does a split occur per schedule line for ...
This can be caused by a change to system behaviour brought about by enhancing delivery creation functions: System behavior up to Release 3.1I:...
Read more >Introduction to RTOS - Solution to Part 3 (Task Scheduling)
FreeRTOS allows us to set priorities for tasks, which allows the scheduler to preempt lower priority tasks with higher priority tasks.
Read more >MICROSOFT PROJECT TASK SPLITTING
Microsoft Project has a function that allows multiple splits in tasks which ... A manually created split is removed by dragging the split...
Read more >Creating and using schedules
Generate and validate schedules in the System Scheduler > Schedules menu. Note: The legacy functions that you may have used, on the System ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That wouldn’t change…
from(whatever)
with no Scheduler would never need a TestScheduler.The change proposed above would obviously not include things like
timer
andinterval
.Done.