Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Shawn Koh
    @shawnkoh
    oh apologies i think i forgot to set equatable on the structs
    haha
    that feels like something that should be enforced by the compiler though, i wonder if store.subscriber's select function should require the struct to conform to Equatable
    Malcolm Jarvis
    @mjarvis
    There is no requirement for equatable structs in state. ReSwift supports non-equatable state, it just can't do repeat skipping. Can you provide an example please?
    Christian Tietze
    @DivineDominion
    Ran into a weird bug in my app that boiled down to a store subscriber caching a value, which didn't mix well with the order of store subscribers being informed of state updates. The general-purpose answer seems to be: put the cache info into the state, not into some service in the app. It's a super weird situation, though, because the cache was introduced to make NSTextView editing a bit less error prone. After all these years, I still wonder if I'm holding it wrong and if doing even more in the ReSwift stack would solve the problems.
    hrln
    @hrln
    hi all! i'm new to this chat and ReSwift - but i've been eyeing it for years. first of all, thanks to the creators and maintainers for bringing this paradigm to native iOS! the ideas have changed the way i write apps
    i'm amidst porting a side project to use ReSwift and am unsure how to resolve certain scenarios. what i'm grappling with right now is chaining asynchronous actions together
    i have a LoadInitialStateAction that resolves with an array of [Item]; i have a middleware guarding for that action, and if it is .loaded(items), i dispatch(someThunk); someThunk being the next asynchronous action that relies on items. what i'm running into is the ReSwift:ConcurrentMutationStateError- Action has been dispatched while a previous action is being processed occurring when my someThunk returns quickly
    i tried wrapping my main store and using a serial queue internally to dispatch, but that didnt work :worried: my fix was basically DispatchQueue.main.asyncAfter(.now() + 1) https://twitter.com/ios_memes/status/1159781903559528450/photo/1
    this seems like a really common need, so i feel like i'm missing something - any advice welcome! (and i'll try to pay it forward with what i learn)
    Christian Tietze
    @DivineDominion
    @hrln the error should only appear when you dispatch from multiple queues. Assuming you dispatch on the main queue by default, DispatchQueue.main.async without a delay should do the trick just as well since the main queue finishes one run loop run, which in your case would be the state mutation, before the next thing is processed.
    Using 2 dispatch queues in your app is not a problem as long as you remember to return to main. It's a good practice to build components in a way that the caller doesn't notice if the queue/thread/... that work is done on is changed. So if you use a BG dispatch queue for networking, dispatch the result back on the main queue, and don't force callers to take care of that.
    hrln
    @hrln
    appreciate the response @DivineDominion ! i did also try the main queue sans delay, but that didn't help :confounded:
    in folks ReSwift setups, are there any techniques you tend to use involving queue management ?
    Christian Tietze
    @DivineDominion
    when the app crashes, you should be able to inspect the stack trace in Xcode to see all active threads and where the culprit might be
    e.g. recently we stumbled upon EKEventStore producing results on an Apple-internal, non-main queue to everyone's surprise
    hrln
    @hrln
    thanks again @DivineDominion :slight_smile: ill dig into the stack trace
    hrln
    @hrln
    i took your advice @DivineDominion, digging into the stack track and wrapping calls that completed on a background queue was the ticket :pray:
    Christian Tietze
    @DivineDominion
    💪 great
    Mehreen7
    @Mehreen7

    Hello everyone, i need to show a little text when my app just start, so im trying to add function into my reducer, into "case _ as ReSwiftInit:" but it dont work, can someone help me ? im new to ReSwift

    Thank you

    Christian Tietze
    @DivineDominion
    What kind of not working do you experience, @Mehreen7 ?
    Mehreen7
    @Mehreen7
    @DivineDominion Hello, so i have my data save in my postgresql table, and i did all the nodejs api stuff, my request is good i test it on postman but when i try to show it on my app it didnt work, i try to print the data it show me "nil" and when i try to print the state of data in my reducer it show me an empty []
    Christian Tietze
    @DivineDominion
    sorry, that's a pretty generic problem, don't know what ReSwift could have to do with that. Could be anything, starting from your DB response handler not being called
    Mehreen7
    @Mehreen7
    Okay thank you @DivineDominion , i have anoter issue, when I try to add a new opertation in AppThunk the former one are not working anymore
    Christian Tietze
    @DivineDominion
    that doesn't sound right, can you share code?
    Mehreen7
    @Mehreen7
    Capture d’écran 2021-02-25 à 11.23.24.png
    yes of course
    Christian Tietze
    @DivineDominion
    hmm the async/await is foreign to me, but one thing I notice is you use StoreDispatch instead of the dispatch func that's passed into the Thunk. Might want to quickly change that for starters.
    What's not working there? Is the await-block never called? Is the thunk's block not executed when you dispatch?
    Mehreen7
    @Mehreen7
    My "AllDailyMsgActionSuccess" is never called
    Christian Tietze
    @DivineDominion
    ah that's easy, op_5 is not part of the await list of concurrent processes
    inside the all(...)
    Mehreen7
    @Mehreen7
    oh no why ?
    Christian Tietze
    @DivineDominion
    you didn't add it? :)
    Mehreen7
    @Mehreen7
    ah yes sorry
    i try to add it to and change the currency too
    but it's still didn't work
    and when i add it, my "AllBadgeActionSuccess" is never called
    Christian Tietze
    @DivineDominion
    Sorry, I don't know the async/await stuff here, and that's clearly not a ReSwift problem but something with the concurrency, so I suggest you ask somewhere where more folks hang around for general Swift questions to increase your chances
    Mehreen7
    @Mehreen7
    oh okay thank you so much for your time
    Christian Tietze
    @DivineDominion
    hope that the op_5 thing I pointed out still helps!
    Mehreen7
    @Mehreen7
    Yes ! :) have a good day !
    Marco Boerner
    @marcoboerner
    Hi there! I've just started using the SwiftUI branch of ReSwift. I was using my own Redux implementation before but ran into several issues with the observers. Does anyone know if the SwiftUI branch has a way to filter the observed state? I know SwiftUI should take care of deciding which parts of the view to redraw but it doesn't seem to work very well. Using a single state always causes my whole view to be redrawn and other undesired behaviour. @mjarvis Do you have any information to that? :)
    Marco Boerner
    @marcoboerner
    Ahh basically described here: ReSwift/ReSwift#461 Never mind then :)
    Malcolm Jarvis
    @mjarvis
    @marcoboerner Sounds like you've found what you're looking for! I'm sorry I've been unable to formalize it more but taking an approach near the bottom of ReSwift/ReSwift#455 should do what you need :)
    Christian Tietze
    @DivineDominion
    Christian Tietze
    @DivineDominion
    I'd love to get a second pair of eyes to talk about my ReSwift approaches in 2 apps eventually. If a ReSwift pro is available for hire for an hour here and there, please email :) https://christiantietze.de/contact/
    Malcolm Jarvis
    @mjarvis
    @DivineDominion Happy to help. send me a dm in the ios slack or something to get in touch.
    Daniel Bergquist
    @BergQuester
    👋
    Christian Tietze
    @DivineDominion
    :wave: