You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just found this library and thought it looked cool and saw that you need either call or apply on subscribe and stream. What is the reason behind that?
The text was updated successfully, but these errors were encountered:
EloB
changed the title
What is the reason why you need to use .call()
What is the reason why you need to use .call() and .apply() on subscribe and/or stream?
Oct 25, 2020
I was thinking of how i could do this myself.
I wanted to turn WebSocket's onMessage event and turn it into a async iterator
I first thought about a own solution before looking into how others have solved it before bringing in any other dependency. to compare my solution to any lib/tool/util fns
my gut says that you don't really need any fancy tools to help out with this, it seems easy do make it yourself with just a few line of codes
sure it dose not have any cancelation or using any addEventListener. but if you build things yourself you get more customizable behavior and don't have to learn a new tools
Need cancelation? sure, you can use AbortController for that with EventTargets newly added signal option.
This can give you one way to stop a lot of things at once if you eg leave a SPA for next page
this can work in Node also, they have added EventTarget and AbortController to the core - in a hope to one day maybe implement fetch on the server, but also for other stuff
asyncfunction*onclick(signal){while(true)yieldawaitnewPromise(rs=>window.addEventListener('click',rs,{once: true, signal })}constabortController=newAbortController()// later abortController.abort()forawait(letevtofonclick(signal))console.log(evt)
Not as much different from how you would write it yourself and if you used a tool, sure your's cover more bases
I just found this library and thought it looked cool and saw that you need either call or apply on subscribe and stream. What is the reason behind that?
The reason was that it was pretty easy to use with the proposed bind operator. But that never really took off.
I just found this library and thought it looked cool and saw that you need either
call
orapply
onsubscribe
andstream
. What is the reason behind that?The text was updated successfully, but these errors were encountered: