Skip to content

Intercept model initialization #24173

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
r-work opened this issue Feb 17, 2021 · 3 comments
Closed

Intercept model initialization #24173

r-work opened this issue Feb 17, 2021 · 3 comments

Comments

@r-work
Copy link

r-work commented Feb 17, 2021

Is it possible to do some model initialization when:

  1. Model is instantiated but before data is written to it.
  2. After data is being written to it.

A small example would be something like the following:

public class MyModel
{
   public ObservableCollection<Item> Items { get; set; }

   public void OnModelCreating()
   {
       this.Items.IsLoading = true;
   }

   public void OnModelCreated()
   {
       this.Items.IsLoading = false;
   }
}
@ajcvickers
Copy link
Contributor

@r-work Can you provide some more details on how this would be useful?

@r-work
Copy link
Author

r-work commented Feb 17, 2021

@ajcvickers this would be similar to EntityLoading and EntityLoaded which is mentioned here, however that issue is about 7 years old, so I presume that's not going to be implemented.

My use case is pretty much the same as what has been described in that issue (copy & paste):

EntityLoading:
After object instance is created but before its properties are initialized. Can be used to reset a flag that will be set in newly created instances but shouldn’t be set during initialization, i.e. for validation.

EntityLoaded:
Can be used to setup anything after an object has been materialized, i.e. event handlers, flags, etc.

@ajcvickers
Copy link
Contributor

@r-work These are covered by #15911 and #10789.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants