Failing test to show that afterMake is run before the model's onLoad hook #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I came across this behaviour that seems a little unexpected, I wonder if it's a bug or maybe something I'm doing wrong... certainly I'm doing something complex and likely very edge-case. This PR provides failing tests to demonstrate the behaviour I'm seeing.
I have a model that sets some derived attributes in a
didLoad
model hook. This works as expected when loading the model normally.However, when I build a model with a factory that has an
afterMake
function I might expect that it theafterMake
function is called so that my model is fully populated before the model's owndidLoad
hook is triggered. This isn't the case however because of the sequencing here:I was trying to think about how this might be reordered and it's not obvious to me whether it could, or even would be worth the complexity that would introduce - you kind-of need a model for the
afterMake
function.Another solution might be to trigger
didLoad
right before returningmodel
, but it might not be ideal to be firing twodidLoad
s:Any thoughts? I'm happy to flesh this PR out with a fix if you could give me some direction :-)