Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute job for both server and client #39

Closed
SleepWalker opened this issue Sep 18, 2017 · 4 comments
Closed

Execute job for both server and client #39

SleepWalker opened this issue Sep 18, 2017 · 4 comments

Comments

@SleepWalker
Copy link

Sometimes you have a work, that should be completed on both sides (server and client), e.g. app initialization.

What do you think about providing a new serverMode, that will allow task to be ran on both sides?

@ctrlplusb
Copy link
Owner

Hmmm, not sure I follow. Do you mind giving me a bit more of an example of what you are trying to achieve?

@SleepWalker
Copy link
Author

I'm implementing i18n for react app. In order to init locale you need:

  • load messages
  • load locale-data
  • load intl polyfill for node/old browsers

I've wrapped this things in redux-thunk. The first two is, actually plain objects, so I can load that data into state. The locale-data should be injected into lib (react-intl), so it is not so straitforward to connect it to the state (but it is possible).

The last one step can not be serialized into the state and must be done on both sides. For node it should be always done, because node includes data only for en locale. For browser only if we deal with safari < 10 and some other old browsers.

Of coarse, I can implement this integration without any react-jobs or asyncBootstrap (my current way to achieve this), but the react-jobs way looks more clean and declarative.

If you don't mind such a feature, I could even create a PR, but first we should decide about an API.

@SleepWalker
Copy link
Author

Another one use case: dynamically loading IoC container chunk for theme-specific react components. They can not be serialized to json and must be loaded on both sides.

@SleepWalker
Copy link
Author

@ctrlplusb what do you think about providing something different to serverMode, so that we can control how the component behaves disregarding where it was executed. It will free the lib from env side effect, which looks to me a little bit confusing and, actually breaks async bootstrapper from crawling the tree. The new option can be shipped as an alternative setup, so that users can migrate. I can provide more details if you interested in such improvements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants