Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    nanocba
    @nanocba
    Anyone has play around with ReThunk and having them to return a promise? The idea is to be able to write code like
    dispatch(thunk).then { // this closure is called once the promise in thunk is fulfilled }. That greatly helps increasing reusability of thunks IMHO.
    Malcolm Jarvis
    @mjarvis
    @nanocba You can wrap the thunk creation in a function such as func foo(params) -> (Thunk, Promise), then use let (thunk, promise) = thunk(params); dispatch(thunk); promise.then { ... } -- This can be wrapped into helper functions and/or extensions on the base types such that you can do so without boilerplate, giving you what you're asking for.
    (eg extension Store { func dispatch(_ thunkAndPromise: (Thunk, Promise)) -> Promise { ... })
    Mycroft Canner
    @mycroftcanner

    How would you model state in a table view driven by an NSFetchResultsController?

    I can let the NSFetchResultsControllerDelegateupdate the table view by inserting, updating, moving and deleting view and when the delegate methodcontrollerDidChangeContent(_:)is called, update the state using the fetch results controller's propertyfetchedObjects`.

    If I use the FRC fetchedObjects and convert my entities to structs I will lose the benefits of faults (large objects can be represented by a fault instead, until they really are needed.) unless I just map fetchedObjects to their objectIDs and only keep the objectIDs in the state and create a state for a cell lazily when it is needed.

    Malcolm Jarvis
    @mjarvis
    I probably would not mix NSFetchResultsController and ReSwift. I'd either get everything into ReSwift somehow (id references or otherwise), or I'd just use NSFetchResultsController directly.
    Xiaoyu Guo
    @MichaelGuoXY
    Hi guys, anyone has any suggestions for this scenario? View A has a state StateA, View B has a state StateB, and both of them share some StateCommon, the question is what's the best practice here to dispatch an action to modify the StateCommon to be adopted by StateA and StateB which are respectively subscribed by View A and View B?
    To be more clear:
    View A subscribes StateA, View B subscribes StateB
    How to let StateA and StateB share some common state? And if any changes happened to that common StateCommon, how to let StateA and StateB know? so that View A and View B would know as well.
    Christian Tietze
    @DivineDominion
    @MichaelGuoXY E.g. instead of newState(_ state: StateB), subscribe to newState(_ state: ViewBState) with struct ViewBState { let stateB: StateB; let commonState: CommonState } (or use tuples)
    Luciano Polit
    @LucianoPolit

    Hey everyone, I hope you are doing good. I would like to share with you a new framework that I have been working on in the last couple of months. It’s called Caesura and it’s powered by ReSwift.
    Main features:

    • Modularization. It’s intended to be feature driven. It decouples your app into small independent modules. Your state will not grow in size any more.
    • Action driven navigation. It’s as flexible as UIKit is.
    • A different way to interact with your API than ReThunk. It’s easy to use and super testable.
    • Optional built-in modules: time traveling, crash detector and reporter, session injection, and more...

    Please, visit the repository for more information and I strongly recommend you to try the example project to see what the framework is capable of.
    Any suggestion is more than welcome, as well as your star ;)
    Cheers!

    Malcolm Jarvis
    @mjarvis
    @LucianoPolit Thanks for the information! I'll be sure to take a look.
    Xiaoyu Guo
    @MichaelGuoXY

    Hey guys, it's me again :) Hope you are doing well. I've been using ReSwift for a year now and there is always some concern in my mind: is it really a good practice to keep all the states/substates in the memory?

    Say I have a view, which dispatches an action to its middleware, the middleware talks to the network service and fetches the data back, after that it fires an action to set the data to its viewState, then the view observed its state changes and reflects that. Everything works perfect. But if I keep doing this for each modules in my app, will it keep increasing the memory usage and some day it might be too high?

    I would like to know what are the todos and not-todos when dealing with various modules with various data (info displayed/stored in the state).

    Malcolm Jarvis
    @mjarvis
    @MichaelGuoXY it is important to keep an eye on memory usage as you test & build your app. Continuously increasing your state can result in memory problems, yes.
    Shawn Koh
    @shawnkoh
    hi all, does anyone know why attempting to dispatch a thunk (from ReSwift-Thunk) leads to recursive dispatch?
    CleanShot 2020-10-06 at 23.57.57.png
    dispatching the fetchProjects thunk leads to a recursive dispatch and crashes the app.
    Malcolm Jarvis
    @mjarvis
    @shawnkoh I don't see anything in that that would cause a recursive dispatch. Could you put together a small example project for us to try?
    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? :)