Open NullVoxPopuli opened 3 years ago
This seems like a great idea! I'll get to working on this in the next few days!
Or of course, PRs are welcome!
@NullVoxPopuli A few thoughts.
trigger
method with their own logic? Is this one tradeoff we have to deal with? Perhaps a more applicable example is if somebody wanted to describe how they determine isInvalid
and do not want to use our get isInvalid
.Another possible approach is the change the api a bit, which would be breaking. The root of the issue right now is that changeset[property] proxies to the underlying data. If we forced using some other property and proxy that, problem solved. Similar to .get, except not using get. Like, changeset.current.property
Class based inheritance should get us all the functionality we need. Prioritizing the following is probably all users need.
Can you help identify why the above prioritization might not work for a user? If we determine this is a bug (which I think it is - we prioritize Changeset over Content), then we can simply fix it.
We could use something like __methods = Symbol.for('ember-changeset-methods')
and export that
export class EC {
[__methods]: {
toString
trigger
...
}
}
But my feeling is class based inheritance is sufficient in this case as long as we have the right prioritization order. Would love to hear your thoughts though!
Well giving #123 a go!
Alright I'm back to this issue 😆 . I completely borked the last PR b/c I thought my partner tests were passing. whispers they weren't.
I'll take a look at this during the week.
Reproduction: https://runkit.com/nullvoxpopuli/reproduction-for-validated-changeset-122
for example,
the data,
trigger
conflicts with: https://github.com/validated-changeset/validated-changeset/blob/ca0c7d249fc2244edaeb7aef25bdf06583628efa/src/index.ts#L144I propose all internal APIS be assigned to private symbols instead of regular keys to not conflict with passed data:
example: