-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Request: please pass the model class to dataTransformer #155
Comments
Curious to understand why you'd need a reference to the constructor? If you're calling If your transformer is anonymously generic then that's a user-land resolution. In the case of the latter, maybe you could use a factory to pass the model reference? |
The data transformer in this case is global and applies to every model. So in the calling code I am using the static FooBar, but in the transformer itself I don't know which model was called as it's generic to every model. |
It would be nice if this plugin would pass the model class as the second argument to the dataTransformer callback so that the dataTransformer function could mutate extra state in the model. Example:
In my model:
Now in the transformer:
I can accomplish this same sort of thing by passing a 'model' into the axios config during the request:
API call:
Then in dataTransformer, use it in
response.config
:However it seems reasonable to me that the plugin would pass in the model and make this cleaner.
The text was updated successfully, but these errors were encountered: