Giter Site home page Giter Site logo

Comments (2)

bolismauro avatar bolismauro commented on August 22, 2024

Hi! Sorry for the very late response.

I don' get why you need concurrent dispatches. Isn't it enough some like this (very simplified example code):

State & Actions:

enum DownloadState {
  case notStarted
  case progress(Double)
  case done
}

// mediaID is a string or something
let media: [MediaID: DownloadState]


struct DownloadMedia: AsyncAction, ActionWithSideEffect {
  let id: MediaID

  // update states to handle start, progress and completion

  sideEffect() {

     let progressClosure = { progress in
       dispatch(self.progressAction({ $0.progress = progress })
     }


     let completionClosure = { localURL in
       dispatch(self.completionAction({ $0.progress = progress })
     }

     dependencies.apiManager.getMedia(self.id, progressClosure, completionClosure)
  }
}

Actions are always sequential, but it doesn't matter because the download is actually parallel if yiu dispatch many DownloadMedia.

For the UI you can attach a listener to the store in the vc that handles the collection/table of bubbles instead of using a listener for each bubble.
Take a look at Tempura, if you haven't seen it https://github.com/BendingSpoons/tempura-swift

I hope it is more clear now

from katana-swift.

fans3210 avatar fans3210 commented on August 22, 2024

@bolismauro , failed to receive notifications from your reply. Thanks a lot for the explanation. I would have a try of this framework. For Reswift, we need to manaage the serial queue manually to make sure all actions dispatched are in the same serial queue to make sure they are sequential

from katana-swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.