@BenLesh While it help to separate state then side effects, you can still inadvertently renter. Often run into this subtle gotcha in redux observables github.com/redux-observab…
This isn't unique to RxJS. This could happen in any system where you're pushing a value through a callback or handler. Hand-rolled event emitters, for example.
2/
Re-entrancy in reactive programming is hard to see.
Basically, anywhere you call a callback (or `next()`), you could be re-entering your function. Make sure important side-effects happen first.
Here's the `take` operator with and without accounting for re-entrancy
1/
@samselikoff Yes, changing it to a const fixes this. It’s more confusing when accessing the outer functions parameter values as parameters are let/mutable by default (but subtlety so), and would therefore unfortunately require you to reassign to a const.
TypeScript wizards: channel is defined on line 9 but possibly undefined on line 12. Any idea why?
#code/DYUwLgBAxgFghgOwSYBnCBeCBtAUBAiAbwEsATALggEYAaCAWxFVTgHNmrs6IAmegMwBdAL618hUpT70mLdpxwAWegFZRuIblyhIsRMmCZo8JClQA6AGYkEZABRRMAPmgXymDFmoBKbSSsIR1NDH2IJAigAewRUKNALYCi2YIMUdzI-CJM04As5Vg5LBjgAB3sChRdwwlroGLiEpJT9MzzyP1qRPxFcIA" target="_blank" rel="nofollow noopener">typescriptlang.org/play?#code/DYU…
@andybudd Reminds me of this quote from Jobs “You know who the best managers are? They’re the great individual contributors, who never ever want to be a manager, but decide they have to be a manager because no one else is going to be able to do as good a job as them.”
A lot of people want to become a manager because they want to be in charge and tell others what to do.
Often the best managers are the ones who don't want to be in charge, but will step up if it means they can help other people, and make things better in the process.
@acemarke Ah yes I think wrap slice would be what I was looking for originally. However there are some pros/cons to adding to an action to weigh up. (Should be able to add sterilisable “context” as opposed to the logger instance it’s self). Thanks 🙏
@robmcm That said, it sounds like you may be attaching a sort of "class instance" or function to the action itself, which strictly speaking isn't something you should be doing in Redux:
#do-not-put-non-serializable-values-in-state-or-actions" target="_blank" rel="nofollow noopener">redux.js.org/style-guide/st…
it'll run, and you can if you _really_ want to, but it's not "right"
@acemarke … I created a middleware to add a logger to the action meta which seems to fit with the state/action pattern. Before RTK we used to “create” a reducer with a logger in the closure, but this isn’t possible with the config approach of creating a slice in toolkit.
@acemarke In this use case it’s a runtime logger (which uploads to server, adds context etc). It’s technically a side effect, but not in terms of affecting state (exceptions aside I guess).
Most business books be like...
Chapter 1. The authors life story
Chapter 2. The actual idea (which could have been a blog post)
Chapters 3-12. Carefully chosen anecdata to prove the idea
As a short cut, you can usually just read chapter 2 and skip the rest.
@acdlite It’s been over a year and I’m still woefully inconsistent, I’m not convinced the people on YouTube are actually using milk… youtu.be/oaKRBBpA4fw