Code Monkey home page Code Monkey logo

Comments (3)

kzaher avatar kzaher commented on July 28, 2024

Use a set overload of feedback loop or create your own feedback loop.

from rxfeedback.swift.

dqw18037 avatar dqw18037 commented on July 28, 2024

@kzaher i updated the question, and the demo address was set.
i hope you can run the demo to make sure you know my question correctly
actually, i didn't understand your reply above
does 'a set overload of feedback loop' mean the 'Set<Query>',
and what do you mean 'create my own feedback loop',
does it means that i can redefine the ' react<State, Query, Event>' function in 'Feedbacks' file?

Thx

from rxfeedback.swift.

eliekarouz avatar eliekarouz commented on July 28, 2024

@dqw18037

The problem is a misusage of the library. You are using Requests which is a reference type as a storage of the requests but IN the query this line state.requestsToSend.all() is mutating the shared storage.
So the next time the query is computed, the previous requests that already fired an effect are not there anymore and their corresponding effects are canceled.

If the above doesn't make sense to you, then think of how you would it if you have only one request.
You would have to encode an optional variable of RequestType in the state and when the optional request becomes != nil then you fire the effect. You return the value back to nil is when you get the response. If you return it back to nil before you receive the response, then no event will be emitted.

Instead of the Requests class just use the Set in the State and keep the RequestType in the Set until you get a response. In case you are not interested in the result of some RequestType remove it from the Set and the flatMapLatest will make sure you don't get any event.

from rxfeedback.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.