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

replaceEnv can now take function as value. #28

Closed
wants to merge 4 commits into from

Conversation

frnk94
Copy link

@frnk94 frnk94 commented May 29, 2015

I use envify to send my configs and some of them are functions. The JSON.stringify(value) return undefined when value is a function.

@yoshuawuyts
Copy link
Collaborator

I'm -1 on this patch; passing functions around as values doesn't seem like a good approach. Consider passing the results of those functions around instead.

@frnk94
Copy link
Author

frnk94 commented May 29, 2015

This functions is uses by my frontend (React components) so i can't just pass the values of the function because it differ according to its state. This function also need to be calculated backend from our ORM

@yoshuawuyts
Copy link
Collaborator

So if I understand you correctly, you want to append functions to process.env to make them available globally and consume them in your components?

@yoshuawuyts
Copy link
Collaborator

Is there a reason you need to build the functions on the server and can't just pass the data to the client?

@frnk94
Copy link
Author

frnk94 commented Nov 23, 2015

This is why I need to pass a function
I want to have constancy in my code base. This function is used by my backend & frontend.
the value pass to the function depend on the state of my application.

exemple:

React.createClass({
    getInitialState() {
        return {
           number: 0,
       }
   },
   calculatePrice() {
        process.env.getPrice(this.state.number);
    },
    render() {
        return (
            <div>{this.calculatePrice()}</div>
       );
   },
});

@yoshuawuyts
Copy link
Collaborator

I feel this complicates things too much and there's very little interest from others. While I appreciate the effort you've put into this I'd rather be forward and close this PR than leave it open and unanswered. Thanks a bunch, but this is not going to land as of now.

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

Successfully merging this pull request may close these issues.

2 participants