Code Monkey home page Code Monkey logo

notify's Introduction

Code Shelter

About Notify

When building WPF and WinForms applications, I often run into the need to know when there is a change in a data-binding data source (which implements INotifyCollectionChanged and/or INotifyPropertyChanged).

For example, imagine an application with a screen for users to edit some settings. By default, the Save button is disabled because no change was made yet. Whenever a user makes a change to the screen, data binding triggers a change to the underlying data source and the Save button should be enabled.

For a simple screen bound to a simple underlying data source, it is easy to just listen to the PropertyChanged or CollectionChanged events and enable the Save button accordingly. For more complicated screens with multiple tabs and nested subviews bound to multiple data sources, this task becomes tedious and error-prone. (Try writing code to track changes to a grand grand grand child of an element which is just added to a collection reachable via a property of a root object! There you go.)

This library is built to simplify change tracking for INotifyCollectionChanged and INotifyPropertyChanged data sources.

Using Notify

Add reference to Notify.dll, e.g. via NuGet

Install-Package Notify 

Next, create a Tracker instance to track your objects and handle its Changed event

var tracker = new Tracker().Track(root1, root2);
tracker.Changed += _ => EnableSave();

// ...sometimes later
tracker.Dispose(); // stop bothering me

That's it! The unit test includes detailed usage of the library. Go take a look and have fun being notified of changes.

Contact

notify's People

Contributors

buunguyen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.