Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 18 14:54
    Andarist commented #2308
  • Aug 18 14:46
    israelidanny commented #2308
  • Aug 18 07:33
    Andarist commented #2308
  • Aug 18 06:03
    israelidanny commented #2308
  • Aug 16 15:45
    changeset-bot[bot] commented #2324
  • Aug 16 15:45
    neurosnap synchronize #2324
  • Aug 16 15:44
    changeset-bot[bot] commented #2324
  • Aug 16 15:44
    neurosnap opened #2324
  • Aug 16 15:25
    dlech opened #2323
  • Aug 13 21:27
    Andarist closed #2319
  • Aug 13 21:27
    Andarist commented #2319
  • Aug 13 21:25

    Andarist on main

    Version Packages (#2322) Co-au… (compare)

  • Aug 13 21:25

    Andarist on main

    (compare)

  • Aug 13 21:25
    Andarist closed #2322
  • Aug 13 21:06
    github-actions[bot] opened #2322
  • Aug 13 21:06

    github-actions[bot] on main

    Version Packages (compare)

  • Aug 13 21:05
    Andarist closed #2280
  • Aug 13 21:03

    Andarist on master

    (compare)

  • Aug 13 21:03

    Andarist on main

    Use `onlyUpdatePeerDependentsWh… Replace all references to the `… (compare)

  • Aug 13 21:03

    Andarist on master

    Use `onlyUpdatePeerDependentsWh… Replace all references to the `… (compare)

Christian Maniewski
@chmanie
Currently we’re using an eventChannel to emit certain external events. What I’d like to do is to just take a certain pattern from it. I guess I’d have to do it like this:
const chan = eventChannel(/* do stuff */);
while (true) {
  const event = yield take(channel);
  if (event.type === ’TYPE_THAT_I_WANT’) {
   // Do a certain thing with an event here
  }
}
I thought I might be able to yield take(channel, ‘TYPE_I_WANT’) but that’s just semantics I guess
Tormen Raßmann
@trassmann
image.png
apparently you can in 1.0 with the new multicastchannel
Christian Maniewski
@chmanie
Yeah that’s what I thought!
The API is a little different though and I wonder whether the multicast channel is meant for internalizing these external sources (like the eventChannel does)
I guess I’m just confused of when to use which channel
Tormen Raßmann
@trassmann
i've never worked with eventChannels, but if you're connecting outside sources that seems to be the way to go
i guess it depends on your use case
you could also write a wrapper that accepts a pattern from that particular channel
or funnel the events into another multicast channel
Christian Maniewski
@chmanie
Mhmm that sounds like a good idea. I’ll think about that, thanks!
Christian Maniewski
@chmanie
I wonder why it’s not possible to have a buffer and support patterns in channels
Tormen Raßmann
@trassmann
you could check the different take implementations
it might make the restrictions of the different channel types more apparent
or just wait till @Andarist chimes in :P
Mateusz Burzyński
@Andarist
if you want standard take(channel) behaviour (unicast) but you want only certain items to be received from it then just do an if statement after take
or dont put unwanted actions on the channel in the first place (not sure if feasible though)
A Flores
@unflores
@chmanie eventChannels use buffers no?
Note: messages on an eventChannel are not buffered by default. You have to provide a buffer to the eventChannel factory in order to specify buffering strategy for the channel (e.g. eventChannel(subscriber, buffer)). See the API docs for more info
Christian Maniewski
@chmanie
@Andarist if I do an if-statement, I basically have to re-implement the matching against strings (types) and patterns. It’s not much but it would be great if I could re-use that
Tormen Raßmann
@trassmann
@chmanie i get the point though, usually you have strict control over what goes into your custom channel no? assuming that, generic matching logic would be overkill
Christian Maniewski
@chmanie
Yeah, I guess you’re right, I probably won’t be needing anything besides string comparisons
Christian Maniewski
@chmanie
I have another question: I’m not entirely sure around the workings of the try-finally construct when using a while(true). How do we get in the finally clause there?
Tormen Raßmann
@trassmann
from w3c: The finally statement lets you execute code, after try and catch, regardless of the result.
i dont understand the question, do you mean why it triggers?
Christian Maniewski
@chmanie
Yeah, what kicks us out of the while(true)
Oh, ok probably an error is thrown
Tormen Raßmann
@trassmann
when any code wrapped in a try block throws an exception the catch/finally will trigger
Christian Maniewski
@chmanie
So take(END) actually throws an error?
Tormen Raßmann
@trassmann
END just kills all takers on the standard channel
so take(END) is kinda redundant
Christian Maniewski
@chmanie
But then it’s caught internally by redux-saga somehow, I guess
Tormen Raßmann
@trassmann
its contradictary actually
A Flores
@unflores
right but to get to finally there has to be an exception thrown right?
Tormen Raßmann
@trassmann

right but to get to finally there has to be an exception thrown right?

yea

Christian Maniewski
@chmanie
Note also we're executing the whole while (true) {...} loop inside a try/finally block. When the interval terminates, the countdown function closes the event channel by invoking emitter(END).
Tormen Raßmann
@trassmann

But then it’s caught internally by redux-saga somehow, I guess

probably you are getting an exception because take(END) is not meant to be done, thats what take.maybe is for

Christian Maniewski
@chmanie
Yeah, I think I was just confused that there’s no error but redux-saga seems to catch that specific one for me
A Flores
@unflores
er nm what am I saying.
This message was deleted
try{ console.log('derp') } catch(err){console.log(err)}finally{console.log('yerp')}
gives 'derp' 'yerp'
so no need for an exception to be thrown
Christian Maniewski
@chmanie
wait, where’s your while(true) @unflores
A Flores
@unflores
I was confused about the usage of finally, no idea how they drop out of while(true) maybe a break somehow?
Christian Maniewski
@chmanie
An exception is needed to break out of this
Tormen Raßmann
@trassmann

so no need for an exception to be thrown

yea it also executes when the try block finishes executing, but it wont in this case since its an endless loop