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

[WIP] use the new store.isFragment method #268

Conversation

GavinJoyce
Copy link

@GavinJoyce GavinJoyce commented Jan 16, 2017

We are currently relying on store.createFragment raising an exception to detect if a model is a factory. This exception comes from an assertion which will be stripped in certain builds once ember-cli/rfcs#50 is adopted.

I recently added a store.isFragment method to ember-data-model-fragments. This hasn't yet been released, but when it is it would be nice to start using it.

TODO:

  • Update the added in 'ember-data-model-fragments' v2.3.x comment once it has been released

@danielspaniel
Copy link
Collaborator

This is pretty great Gavin.
Should have thought to do this myself because the other day I was looking at that method and was not loving it because the try catch was swallowing an exception ( mistake I was making ) in my test ( which made it hard / nearly impossible to detect ).
I did not think to add what you did ( a nice method in the fragment addon ) .. so 'heck yeah' to this.
Let me know as soon as that new version is ready.

@GavinJoyce GavinJoyce force-pushed the gj/store-is-fragment branch from 5e8b416 to 94b8788 Compare January 21, 2017 07:14
@GavinJoyce
Copy link
Author

@danielspaniel ember-data-model-fragments 2.11.0 has been released so I think this is ready to go now

@danielspaniel
Copy link
Collaborator

How should I handle this for people who have not updated to 2.11 fragments.
I saw the thread in the fragments PR and yes, I should have used Fragment.detect, I just did not know about that method.
What I am thinking is that I could just copy what you are doing is that method

  let type = store.modelFor(modelName);
  Fragment.detect(type); 

rather than use the method store.isFragment since then people are forced to update to 2.11 fragments .. know what I mean. Thoughts?

@GavinJoyce
Copy link
Author

Thanks sounds fine @danielspaniel, feel free to close this PR if you go down that route

@danielspaniel
Copy link
Collaborator

I will close this then @GavinJoyce , because I converted that method to use your code from that method and it works fine now. Much better .. so thanks again.

@GavinJoyce GavinJoyce deleted the gj/store-is-fragment branch January 21, 2017 20:16
@danielspaniel
Copy link
Collaborator

Release:
https://github.com/danielspaniel/ember-data-factory-guy/releases/tag/v2.10.1
has the better implemented fragment checker ( copied from you )

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