michaellperry / Assisticant

MIT License
36 stars 19 forks source link

Data Validation and Editable support #17

Closed GautamAgrawal closed 6 years ago

GautamAgrawal commented 9 years ago

Hi ! I have seen your library and it is very nice library for mvvm support . I have a query. How can it provide support for editable objects and IDataErrorInfo objects. I want to use them using your library.

Thanks

michaellperry commented 9 years ago

The platform proxy wrapper simply passes IDataErrorInfo and IEditableObject through to the wrapped object. So if you implement those interfaces, you can still use ViewModel(() => ) or ForView.Wrap() in your objects and get the benefits you're looking for.

The library does not provide any additional support beyond pass-through.

GautamAgrawal commented 9 years ago

Thank you Michaell , I have one more question that in this library "FirePropertyChanged" event is fired for all properties and it contains the reference of the properties. Will it not be the cause of any performance issue in case of there are lot of properties and the nested properties . It will keep firing the "FirePropertyChanged" event. Please suggest because I notice this the main important thing in case of performance.

michaellperry commented 9 years ago

No, that's not accurate. The PropertyChanged event is only fired for the properties that actually change. And special care has been taken to avoid event storms.

First, by nested properties I assume that you are referring to properties of objects that are themselves reached via properties. Like the AddressBook having a People property that returns Person objects, each having a Name property. If the Name changes, then PropertyChanged("Name") fires on only the one Person. And if a person is added or removed, then CollectionChanged fires only on the People.

Second, the UpdateScheduler saves all events until the update phase. When something changes, it calls UpdateScheduler.ScheduleUpdate. It does not immediately fire PropertyChanged or CollectionChanged. Then, after all changes are complete, the UpdateScheduler runs the updates in the proper order so that each one occurs only once.

Third, objects are recycled. When a collection changes, any objects that remain in the collection are reused, so their properties do not need to be updated.

You can test the performance of these optimizations by applying a value converter. Use a trace point to count the number of times that a property is read.

Let me know if you find a performance problem.

Collosangy05 commented 7 years ago

Awesome work just saw your pluralsight video and I was impressed. Good good work

michaellperry commented 6 years ago

Validation has been added.