GithubHelp home page GithubHelp logo

Comments (11)

catamphetamine avatar catamphetamine commented on July 4, 2024

Why do you think http is only available on client side?

from react-pages.

vetrslav avatar vetrslav commented on July 4, 2024

I know that it's universal but as I understand this utility is available only in your middleware for async actions, and i want something like this in redux-thunk
I've tried to use getHttpClient() but it gave me an error that window is not defined on server side.

from react-pages.

catamphetamine avatar catamphetamine commented on July 4, 2024

I know that it's universal but as I understand this utility is avilable only in your middleware for async actions, and i want something like this in redux-thunk

I see.
Well, there is no global variable on server-side so getHttpClient() doesn't work there.
Instead, http client could be stored somewhere in store, like store.httpClient = httpClient but then how would one access store from an action... I guess it's not correct to access store from an action. In Redux, there's no way actually to access store directly, only getState(), but httpClient can't be stored in state because it's not a JSON object.

from react-pages.

catamphetamine avatar catamphetamine commented on July 4, 2024

I'll close this for now as "not possible".
Still you can write comments here.

from react-pages.

vetrslav avatar vetrslav commented on July 4, 2024

ok, thanks
Yeah, that's it
I found something like workaround for this
workaround is to export some global variable (for example httpUtility) in source / redux / store.js
and to set
httpUtility = http_client
inside create_store function
it solves my needs
But i want it to be in npm package
Could you please add this in new version?
I think that this workaround is ok as i understand because we will use httpUtility always after the store is created
and it always gonna return correct http utility as on client and as on server

from react-pages.

catamphetamine avatar catamphetamine commented on July 4, 2024

I don't understand, which exact variable do you set inside create_store function.
You can post some actual code.

from react-pages.

vetrslav avatar vetrslav commented on July 4, 2024

image
something like this in source / redux / store.js

from react-pages.

catamphetamine avatar catamphetamine commented on July 4, 2024

You can't share an httpClient between several users.
If you store it in a global variable then many users are using it simultaneously.
It's not supposed to be used like that: it should be constructed anew for each page for each user.

from react-pages.

vetrslav avatar vetrslav commented on July 4, 2024

I get it, ok i will use common react-website approach for async actions.
thanks :)

from react-pages.

catamphetamine avatar catamphetamine commented on July 4, 2024

You should be able to do anything using the common react-website approach for async actions.
If there's a use-case where something is not possible then you can post it here.

from react-pages.

vetrslav avatar vetrslav commented on July 4, 2024

ok, thanks

from react-pages.

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.