store icon indicating copy to clipboard operation
store copied to clipboard

refactor(connectTo): Call the change handler after value is set

Open jmzagorski opened this issue 6 years ago • 3 comments

Change this logic to align with Aurelia's change handling method invocation for view model properties. @bindable and @observable both call the property change method after the value is set. This change simply flips the order they are called in the decorator

closes #69 BREAKING CHANGE: the property value being changed will be set and equal to the newVal parameter when its change handler is invoked. To migrate from old code, get the old value from the oldValue parameter in the method call instead of getting a value from the view model property

jmzagorski avatar Nov 04 '18 15:11 jmzagorski

Thanks thats great. The problem is still the breaking behavior, so I guess we need to update the docs as well. I'll check this tomorrow and will merge this

zewa666 avatar Nov 04 '18 19:11 zewa666

To be honest, I only did this since I called myself out in #69 to fix this and did not want to keep anyone waiting. However, after I finished and wrote the commit message with the breaking change I doubted a merge since it may bump a major version. Maybe this should wait until a v2.0? It really is not a huge change as you can see.

We could handle #69 in another way since that issue brought up property decorators. I started using typescript and ditched the connectTo decorator in favor of two property decorators i created, @select and @action. In the @select decorator I invoke the change handling methods after I set the value, which follows Aurelia's observable behavior and satisfies #69. This would make the connectTo and select act differently, but with proper documentation that might be okay. What do you think?

jmzagorski avatar Nov 05 '18 02:11 jmzagorski

Exactly what I thought. Had a local branch with the same changes and was holding off a bit due to the breaking change. Sooner or later we'll definitely have this merged as V2.

I'd be interested to see what you did with the select and action decorators. Tbvh I pretty much never use connectTo either since I prefer to have full subscription control, so I'm open for any ideas here. Maybe post in the mentioned issue or create a new one as suggestion

zewa666 avatar Nov 05 '18 06:11 zewa666