Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upoperators definition conflicting with ReactiveX/rxjs definition. "They return a function" vs "should return an observable" #35183
Comments
|
Dear @ghuser
IMHO the whole sentence is useless. :D What you should fouse about is:
Observable: Static: const arr = [1,2,3,4];
const o = new Observable((subscriber => {
arr.foeEach(n => subscriber.next(n))
subscriber.complete()
}));Creation Function: const arr = [1,2,3,4];
function createObserfableFromArray(arr) => {
return new Observable((subscriber => {
arr.foeEach(n => subscriber.next(n))
subscriber.complete()
}));
}
const o =createObserfableFromArray = (arr) ;Operators Static: function log(observable) => {
return observable.pipe(tap(value => console.log(value)));
}
observable.pipe(
log
)Creation Function: function logCreation(param) {
return function(observable) => {
return observable.pipe(
tap(value => console.log(param, value))
);
}
}
observable.pipe(
logCreation('value: ')
)To sum up: Operators are functions that take an Observable and return an observable:
Observables can be created by using instantiating a new one:
Let me know if this helps. Best, |
|
Thank you so much, @BioPhoton!! @ghuser, does that help you? We can also clear up the docs on this point. |
|
It is more clear now, though this syntax confuses me. Is it valid js?:
and
|
|
Status: Docs Team can use the excellent explanation by @BioPhoton to update the documentation. |


Description
In the section https://angular.io/guide/rx-library#operators there is a definition of an operator:
But in rxjs guidelines about operation creation they say:
Clearly there is a conflicting definition: "they return a function"" vs "should always return an observable".
What's the affected URL?**
https://angular.io/guide/rx-library#operators
Reproduction Steps**
Expected vs Actual Behavior**
Browser info
Anything else relevant?