RxJS “dot” vs “pipe” abstraction The 2019 Stack Overflow Developer Survey Results Are InWhat do these three dots in React do?What is the correct way to share the result of an Angular Http network call in RxJs 5?How to get current value of RxJS Subject or Observable?Angular/RxJs When should I unsubscribe from `Subscription`Rxjs: Observable.combineLatest vs Observable.forkJoinWhat is pipe for in rxJSPipe RxJS observable to existing subjectUse RxJs Pipe to reduce Observable to different typeRxJS Pipe Not Called With zipGet extra details via pipe operator with rxjs
Why could you hear an Amstrad CPC working?
In microwave frequencies, do you use a circulator when you need a (near) perfect diode?
Is this food a bread or a loaf?
How to reverse every other sublist of a list?
Does duplicating a spell with Wish count as casting that spell?
Understanding the implication of what "well-defined" means for the operation in quotient group
Access elements in std::string where positon of string is greater than its size
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
What is the meaning of Triage in Cybersec world?
I looked up a future colleague on LinkedIn before I started a job. I told my colleague about it and he seemed surprised. Should I apologize?
What does "rabbited" mean/imply in this sentence?
What is the best strategy for white in this position?
Is three citations per paragraph excessive for undergraduate research paper?
Unbreakable Formation vs. Cry of the Carnarium
What is the use of option -o in the useradd command?
How can I create a character who can assume the widest possible range of creature sizes?
What do the Banks children have against barley water?
What effect does the “loading” weapon property have in practical terms?
Inversion Puzzle
Is flight data recorder erased after every flight?
How was Skylab's orbit inclination chosen?
Why is the maximum length of OpenWrt’s root password 8 characters?
Geography at the pixel level
Where does the "burst of radiance" from Holy Weapon originate?
RxJS “dot” vs “pipe” abstraction
The 2019 Stack Overflow Developer Survey Results Are InWhat do these three dots in React do?What is the correct way to share the result of an Angular Http network call in RxJs 5?How to get current value of RxJS Subject or Observable?Angular/RxJs When should I unsubscribe from `Subscription`Rxjs: Observable.combineLatest vs Observable.forkJoinWhat is pipe for in rxJSPipe RxJS observable to existing subjectUse RxJs Pipe to reduce Observable to different typeRxJS Pipe Not Called With zipGet extra details via pipe operator with rxjs
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
RsJs moved from a "dot" to a "pipe" abstraction for its operators for these four reasons. Would those reasons have also been addressed if the operators were aliased with symbols? So instead of adding a property named 'myOp'
to the prototype, what if the name were a symbol like Symbol('myOp')
? Then it could be invoked as
var MyOp = require('my-op');
var o = getObservable();
var x = o[MyOp]();
Taking the justifications one-by-one:
Any library that imports a patch operator will augment the Observable.prototype for all consumers of that library, creating blind dependencies. If the library removes their usage, they unknowingly break everyone else. With pipeables, you have to import the operators you need into each file you use them in.
The symbol would only be attached to the prototype when the module is loaded via require('myOp')
and wouldn't collide because it's a symbol and wouldn't be removed.
Operators patched directly onto the prototype are not "tree-shakeable" by tools like rollup or webpack. Pipeable operators will be as they are just functions pulled in from modules directly.
Symbols added to the prototype would not need to be shaken because they're imported one-by-one as needed; If the symbol is present on the prototype then it's being used by whoever imported it.
Unused operators that are being imported in apps cannot be detected reliably by any sort of build tooling or lint rule. That means that you might import scan, but stop using it, and it's still being added to your output bundle. With pipeable operators, if you're not using it, a lint rule can pick it up for you.
Symbols that are loaded but not used are easy to detect; If var MyOp = require('my-op')
and MyOp
is not used, then the linter could ask that the package be removed and so the op would never be attached as the module is never loaded.
Functional composition is awesome. Building your own custom operators becomes much, much easier, and now they work and look just like all other operators from rxjs. You don't need to extend Observable or override lift anymore.
The module my-op
would declare the operator like so:
var MyOp = Symbol('MyOp');
Observable.prototype[MyOp] = function() ...
module.exports = MyOp
javascript angular rxjs rxjs5 rxjs-pipeable-operators
|
show 4 more comments
RsJs moved from a "dot" to a "pipe" abstraction for its operators for these four reasons. Would those reasons have also been addressed if the operators were aliased with symbols? So instead of adding a property named 'myOp'
to the prototype, what if the name were a symbol like Symbol('myOp')
? Then it could be invoked as
var MyOp = require('my-op');
var o = getObservable();
var x = o[MyOp]();
Taking the justifications one-by-one:
Any library that imports a patch operator will augment the Observable.prototype for all consumers of that library, creating blind dependencies. If the library removes their usage, they unknowingly break everyone else. With pipeables, you have to import the operators you need into each file you use them in.
The symbol would only be attached to the prototype when the module is loaded via require('myOp')
and wouldn't collide because it's a symbol and wouldn't be removed.
Operators patched directly onto the prototype are not "tree-shakeable" by tools like rollup or webpack. Pipeable operators will be as they are just functions pulled in from modules directly.
Symbols added to the prototype would not need to be shaken because they're imported one-by-one as needed; If the symbol is present on the prototype then it's being used by whoever imported it.
Unused operators that are being imported in apps cannot be detected reliably by any sort of build tooling or lint rule. That means that you might import scan, but stop using it, and it's still being added to your output bundle. With pipeable operators, if you're not using it, a lint rule can pick it up for you.
Symbols that are loaded but not used are easy to detect; If var MyOp = require('my-op')
and MyOp
is not used, then the linter could ask that the package be removed and so the op would never be attached as the module is never loaded.
Functional composition is awesome. Building your own custom operators becomes much, much easier, and now they work and look just like all other operators from rxjs. You don't need to extend Observable or override lift anymore.
The module my-op
would declare the operator like so:
var MyOp = Symbol('MyOp');
Observable.prototype[MyOp] = function() ...
module.exports = MyOp
javascript angular rxjs rxjs5 rxjs-pipeable-operators
1
I think you've answered your own question. Anyway, I would not want to writesource[Map](x => x + 1)[Filter](x => x % 2);
Also, thepipe
approach will work nicely with the pipeline proposal - if it's incorporated into the language.
– cartant
Mar 22 at 3:20
Fair enough! I just figured theSymbol
way wouldn't require thepipe
method but if JS is adding a whole new operator to replace thepipe
method then that's great.
– Christopher King
Mar 22 at 3:45
Tho if symbols were used then we wouldn't need the|>
operator either. Everyone loves syntactic sugar, but a new operator is seems a high price to pay for a fluent syntax that we could have today using symbols, no? So I was wondering if there were other obstacles that would preclude a symbol approach or is it just that the bracket syntax simply too jarring? To answer my own question again, one issue I could see is that the tooling support for symbols is not great. But then I'd think fixing tooling would be simpler than adding a new operator...
– Christopher King
Mar 22 at 4:07
To plays Devil's Advocate again, while the symbol approach can be done today, it does requires the data traversing the pipe be passed in thethis
argument where as with the|>
operator it is passed as a proper argument. This has an effect for primitives like numbers (I think) which would be boxed if passed viathis
but not if passed as a propert argument. While I'm not sure that'd affect RxJs which is piping Observable objects, it would affect examples like the linked example that passes numbers.
– Christopher King
Mar 22 at 4:13
The symbol approach also has the disadvantage of being problematic with ASI.
– cartant
Mar 22 at 5:03
|
show 4 more comments
RsJs moved from a "dot" to a "pipe" abstraction for its operators for these four reasons. Would those reasons have also been addressed if the operators were aliased with symbols? So instead of adding a property named 'myOp'
to the prototype, what if the name were a symbol like Symbol('myOp')
? Then it could be invoked as
var MyOp = require('my-op');
var o = getObservable();
var x = o[MyOp]();
Taking the justifications one-by-one:
Any library that imports a patch operator will augment the Observable.prototype for all consumers of that library, creating blind dependencies. If the library removes their usage, they unknowingly break everyone else. With pipeables, you have to import the operators you need into each file you use them in.
The symbol would only be attached to the prototype when the module is loaded via require('myOp')
and wouldn't collide because it's a symbol and wouldn't be removed.
Operators patched directly onto the prototype are not "tree-shakeable" by tools like rollup or webpack. Pipeable operators will be as they are just functions pulled in from modules directly.
Symbols added to the prototype would not need to be shaken because they're imported one-by-one as needed; If the symbol is present on the prototype then it's being used by whoever imported it.
Unused operators that are being imported in apps cannot be detected reliably by any sort of build tooling or lint rule. That means that you might import scan, but stop using it, and it's still being added to your output bundle. With pipeable operators, if you're not using it, a lint rule can pick it up for you.
Symbols that are loaded but not used are easy to detect; If var MyOp = require('my-op')
and MyOp
is not used, then the linter could ask that the package be removed and so the op would never be attached as the module is never loaded.
Functional composition is awesome. Building your own custom operators becomes much, much easier, and now they work and look just like all other operators from rxjs. You don't need to extend Observable or override lift anymore.
The module my-op
would declare the operator like so:
var MyOp = Symbol('MyOp');
Observable.prototype[MyOp] = function() ...
module.exports = MyOp
javascript angular rxjs rxjs5 rxjs-pipeable-operators
RsJs moved from a "dot" to a "pipe" abstraction for its operators for these four reasons. Would those reasons have also been addressed if the operators were aliased with symbols? So instead of adding a property named 'myOp'
to the prototype, what if the name were a symbol like Symbol('myOp')
? Then it could be invoked as
var MyOp = require('my-op');
var o = getObservable();
var x = o[MyOp]();
Taking the justifications one-by-one:
Any library that imports a patch operator will augment the Observable.prototype for all consumers of that library, creating blind dependencies. If the library removes their usage, they unknowingly break everyone else. With pipeables, you have to import the operators you need into each file you use them in.
The symbol would only be attached to the prototype when the module is loaded via require('myOp')
and wouldn't collide because it's a symbol and wouldn't be removed.
Operators patched directly onto the prototype are not "tree-shakeable" by tools like rollup or webpack. Pipeable operators will be as they are just functions pulled in from modules directly.
Symbols added to the prototype would not need to be shaken because they're imported one-by-one as needed; If the symbol is present on the prototype then it's being used by whoever imported it.
Unused operators that are being imported in apps cannot be detected reliably by any sort of build tooling or lint rule. That means that you might import scan, but stop using it, and it's still being added to your output bundle. With pipeable operators, if you're not using it, a lint rule can pick it up for you.
Symbols that are loaded but not used are easy to detect; If var MyOp = require('my-op')
and MyOp
is not used, then the linter could ask that the package be removed and so the op would never be attached as the module is never loaded.
Functional composition is awesome. Building your own custom operators becomes much, much easier, and now they work and look just like all other operators from rxjs. You don't need to extend Observable or override lift anymore.
The module my-op
would declare the operator like so:
var MyOp = Symbol('MyOp');
Observable.prototype[MyOp] = function() ...
module.exports = MyOp
javascript angular rxjs rxjs5 rxjs-pipeable-operators
javascript angular rxjs rxjs5 rxjs-pipeable-operators
asked Mar 22 at 2:49
Christopher KingChristopher King
5361413
5361413
1
I think you've answered your own question. Anyway, I would not want to writesource[Map](x => x + 1)[Filter](x => x % 2);
Also, thepipe
approach will work nicely with the pipeline proposal - if it's incorporated into the language.
– cartant
Mar 22 at 3:20
Fair enough! I just figured theSymbol
way wouldn't require thepipe
method but if JS is adding a whole new operator to replace thepipe
method then that's great.
– Christopher King
Mar 22 at 3:45
Tho if symbols were used then we wouldn't need the|>
operator either. Everyone loves syntactic sugar, but a new operator is seems a high price to pay for a fluent syntax that we could have today using symbols, no? So I was wondering if there were other obstacles that would preclude a symbol approach or is it just that the bracket syntax simply too jarring? To answer my own question again, one issue I could see is that the tooling support for symbols is not great. But then I'd think fixing tooling would be simpler than adding a new operator...
– Christopher King
Mar 22 at 4:07
To plays Devil's Advocate again, while the symbol approach can be done today, it does requires the data traversing the pipe be passed in thethis
argument where as with the|>
operator it is passed as a proper argument. This has an effect for primitives like numbers (I think) which would be boxed if passed viathis
but not if passed as a propert argument. While I'm not sure that'd affect RxJs which is piping Observable objects, it would affect examples like the linked example that passes numbers.
– Christopher King
Mar 22 at 4:13
The symbol approach also has the disadvantage of being problematic with ASI.
– cartant
Mar 22 at 5:03
|
show 4 more comments
1
I think you've answered your own question. Anyway, I would not want to writesource[Map](x => x + 1)[Filter](x => x % 2);
Also, thepipe
approach will work nicely with the pipeline proposal - if it's incorporated into the language.
– cartant
Mar 22 at 3:20
Fair enough! I just figured theSymbol
way wouldn't require thepipe
method but if JS is adding a whole new operator to replace thepipe
method then that's great.
– Christopher King
Mar 22 at 3:45
Tho if symbols were used then we wouldn't need the|>
operator either. Everyone loves syntactic sugar, but a new operator is seems a high price to pay for a fluent syntax that we could have today using symbols, no? So I was wondering if there were other obstacles that would preclude a symbol approach or is it just that the bracket syntax simply too jarring? To answer my own question again, one issue I could see is that the tooling support for symbols is not great. But then I'd think fixing tooling would be simpler than adding a new operator...
– Christopher King
Mar 22 at 4:07
To plays Devil's Advocate again, while the symbol approach can be done today, it does requires the data traversing the pipe be passed in thethis
argument where as with the|>
operator it is passed as a proper argument. This has an effect for primitives like numbers (I think) which would be boxed if passed viathis
but not if passed as a propert argument. While I'm not sure that'd affect RxJs which is piping Observable objects, it would affect examples like the linked example that passes numbers.
– Christopher King
Mar 22 at 4:13
The symbol approach also has the disadvantage of being problematic with ASI.
– cartant
Mar 22 at 5:03
1
1
I think you've answered your own question. Anyway, I would not want to write
source[Map](x => x + 1)[Filter](x => x % 2);
Also, the pipe
approach will work nicely with the pipeline proposal - if it's incorporated into the language.– cartant
Mar 22 at 3:20
I think you've answered your own question. Anyway, I would not want to write
source[Map](x => x + 1)[Filter](x => x % 2);
Also, the pipe
approach will work nicely with the pipeline proposal - if it's incorporated into the language.– cartant
Mar 22 at 3:20
Fair enough! I just figured the
Symbol
way wouldn't require the pipe
method but if JS is adding a whole new operator to replace the pipe
method then that's great.– Christopher King
Mar 22 at 3:45
Fair enough! I just figured the
Symbol
way wouldn't require the pipe
method but if JS is adding a whole new operator to replace the pipe
method then that's great.– Christopher King
Mar 22 at 3:45
Tho if symbols were used then we wouldn't need the
|>
operator either. Everyone loves syntactic sugar, but a new operator is seems a high price to pay for a fluent syntax that we could have today using symbols, no? So I was wondering if there were other obstacles that would preclude a symbol approach or is it just that the bracket syntax simply too jarring? To answer my own question again, one issue I could see is that the tooling support for symbols is not great. But then I'd think fixing tooling would be simpler than adding a new operator...– Christopher King
Mar 22 at 4:07
Tho if symbols were used then we wouldn't need the
|>
operator either. Everyone loves syntactic sugar, but a new operator is seems a high price to pay for a fluent syntax that we could have today using symbols, no? So I was wondering if there were other obstacles that would preclude a symbol approach or is it just that the bracket syntax simply too jarring? To answer my own question again, one issue I could see is that the tooling support for symbols is not great. But then I'd think fixing tooling would be simpler than adding a new operator...– Christopher King
Mar 22 at 4:07
To plays Devil's Advocate again, while the symbol approach can be done today, it does requires the data traversing the pipe be passed in the
this
argument where as with the |>
operator it is passed as a proper argument. This has an effect for primitives like numbers (I think) which would be boxed if passed via this
but not if passed as a propert argument. While I'm not sure that'd affect RxJs which is piping Observable objects, it would affect examples like the linked example that passes numbers.– Christopher King
Mar 22 at 4:13
To plays Devil's Advocate again, while the symbol approach can be done today, it does requires the data traversing the pipe be passed in the
this
argument where as with the |>
operator it is passed as a proper argument. This has an effect for primitives like numbers (I think) which would be boxed if passed via this
but not if passed as a propert argument. While I'm not sure that'd affect RxJs which is piping Observable objects, it would affect examples like the linked example that passes numbers.– Christopher King
Mar 22 at 4:13
The symbol approach also has the disadvantage of being problematic with ASI.
– cartant
Mar 22 at 5:03
The symbol approach also has the disadvantage of being problematic with ASI.
– cartant
Mar 22 at 5:03
|
show 4 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292196%2frxjs-dot-vs-pipe-abstraction%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292196%2frxjs-dot-vs-pipe-abstraction%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I think you've answered your own question. Anyway, I would not want to write
source[Map](x => x + 1)[Filter](x => x % 2);
Also, thepipe
approach will work nicely with the pipeline proposal - if it's incorporated into the language.– cartant
Mar 22 at 3:20
Fair enough! I just figured the
Symbol
way wouldn't require thepipe
method but if JS is adding a whole new operator to replace thepipe
method then that's great.– Christopher King
Mar 22 at 3:45
Tho if symbols were used then we wouldn't need the
|>
operator either. Everyone loves syntactic sugar, but a new operator is seems a high price to pay for a fluent syntax that we could have today using symbols, no? So I was wondering if there were other obstacles that would preclude a symbol approach or is it just that the bracket syntax simply too jarring? To answer my own question again, one issue I could see is that the tooling support for symbols is not great. But then I'd think fixing tooling would be simpler than adding a new operator...– Christopher King
Mar 22 at 4:07
To plays Devil's Advocate again, while the symbol approach can be done today, it does requires the data traversing the pipe be passed in the
this
argument where as with the|>
operator it is passed as a proper argument. This has an effect for primitives like numbers (I think) which would be boxed if passed viathis
but not if passed as a propert argument. While I'm not sure that'd affect RxJs which is piping Observable objects, it would affect examples like the linked example that passes numbers.– Christopher King
Mar 22 at 4:13
The symbol approach also has the disadvantage of being problematic with ASI.
– cartant
Mar 22 at 5:03