Giter Club home page Giter Club logo

Comments (5)

ventrz avatar ventrz commented on May 23, 2024

maybe I just didn't get you right, huh, but what if:

  1. Resolved, Rejected, Running sub-components are maximum dumb and they will be used just to render passed children conditionally, and DON'T PASS ANY DATA to children at all
  2. Move data layer to Result (or smth like this) component, which will be used to get fetched (or accumulated) data

from react-async-call.

kuzn-ilya avatar kuzn-ilya commented on May 23, 2024

Not sure that having dumb component for promise lifecycle will be handy, because, for example, if you catch an error you defintely should know what went wrong. So, API for theirs children should be (IMHO) as follows:

  1. Running - supports only React children, not function. So here we have what you want.
  2. Rejected - supports React children as well as children function with one argument - rejectReason
  3. Resolved - supports React children as well as children function with one argument - result. This might be suitable for simple use cases: e.g. if you don't need to collect results between promise resolving and don't want to render anything during promise function run.

In any case, passing function as a child is up to you. If you don't need it, just pass regular react children :)

from react-async-call.

ventrz avatar ventrz commented on May 23, 2024

Yep, missed the case with Rejected component.
But still have some concerns about Result and Resolved components: both of them expose fetched data, but Resolved renders its children depending on Promise state.

So, my thought is just to have only one way to get fetched data.

from react-async-call.

kuzn-ilya avatar kuzn-ilya commented on May 23, 2024

Hm... It seems like I got your point. If Resolved won't take a children func, it will be still possible to implement my case using composition like this:

<PromiseRenderer.Resolved>
  <PromiseRenderer.Result>
    {result => ...}
  </PromiseRenderer.Result>
</PromiseRenderer.Resolved>

So, agree, ability to pass function to Resolved children should be removed.

from react-async-call.

kuzn-ilya avatar kuzn-ilya commented on May 23, 2024

I am closing this issue, because of changing API is not the best thing after a few month of package usage.

from react-async-call.

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.