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

Derive :namespace only when key is present #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sitch
Copy link

@sitch sitch commented Apr 8, 2018

Currently namespace will be overridden by any extended model regardless of whether it includes a :namespace field or not

Currently namespace will be overridden by any extended model regardless of whether it includes a :namespace field or not
@benjycui
Copy link
Member

benjycui commented Apr 9, 2018

The use case?

I don't understand why do you need to share namespace with other models.

@MengWeiChen
Copy link

I think the use case is when you use umi, you don't need to write namespace in the model.

If this library override namespace whether it includes namespace field or not, the output model from this library, which namespace field will be underfined and that will cause dva crash on the runtime.

@sitch
Copy link
Author

sitch commented Aug 14, 2018

I expected modelExtend to be commutative in the no key collision case, and when there is a collision, it should take the last argument to define that property. This is consistent with Object.assigns()

This just seems weird/buggy/bad rationale

const { namespace } = modelExtend({}, {namespace: "users"}) 
// namespace => "users"

const { namespace } = modelExtend({namespace: "users"}, {}) 
// namespace => undefined ????? huh ???

My original use case was composing common tasks (crud / socket listeners / forms) via functions and folding them into the model.

@chapskev
Copy link

chapskev commented Nov 6, 2018

@sitch how did you manage to use umi with dva-model-extend? Will greatly appreciate your response.

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.

None yet

4 participants