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;








0















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









share|improve this question

















  • 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











  • 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











  • 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


















0















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









share|improve this question

















  • 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











  • 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











  • 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














0












0








0








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









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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











  • 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












  • The symbol approach also has the disadvantage of being problematic with ASI.

    – cartant
    Mar 22 at 5:03













  • 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











  • 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











  • 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








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













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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현