question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce a "OnChangedMethod" attribute

See original GitHub issue
class MyClass : INotifyPropertyChanged 
{
    [OnChangedMethod(nameof(OnMyPropertyChanged))]
    int MyProperty { get; set; }

    void OnMyPropertyChanged()
    {
    }
}

Since we have a nameof operator today, we could decorate the property with a “link” to the on changed method. This will avoid the problems with renaming, and omit the compiler warnings that OnMyPropertyChanged is never used. It also will allow direct navigation to the method from the property.

This attribute would be optional, for those who like to use it. To be fully backward compatible, the weaver would only check that, if the attribute is present, the name of the method matches the desired pattern.

#447 could then also give a hint to properly decorate the property.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ltrzesniewskicommented, Oct 19, 2019

It would need a few changes but not that much (basically adding the method info to PropertyData).

Also, we could allow the user to provide multiple OnChangedMethod attributes, to call multiple methods when a property changes.

0reactions
ltrzesniewskicommented, Nov 10, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML onchange Event Attribute
The onchange attribute fires the moment when the value of the element is changed. Tip: This event is similar to the oninput event....
Read more >
How onchange Event work in JavaScript | Examples
The onchange event is one of the events in JavaScript which is used for making the change in the state and transforming the...
Read more >
onchange attribute: what exactly is the context when calling ...
So in the code, I am referring to checkBox.setAttribute("onchange","checkedBoxes()"), and the function is at the bottom. The HTML is really not ...
Read more >
HTML DOM onchange Event
The HTML DOM onchange event occurs when the value of an element has been changed. It also works with radio buttons and checkboxes...
Read more >
onChange Javascript
Onchange as Event Attribute. When the changes are made on the select element, a custom function “function” is called through the onchange ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found