IModel.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using JetBrains.Annotations;
  3. using Unity.Cloud.Collaborate.UserInterface;
  4. namespace Unity.Cloud.Collaborate.Models
  5. {
  6. internal interface IModel
  7. {
  8. /// <summary>
  9. /// Inform the presenter that the state of the model has changed.
  10. /// </summary>
  11. event Action StateChanged;
  12. /// <summary>
  13. /// Called when the model is started and the model should setup events and fetch data.
  14. /// </summary>
  15. void OnStart();
  16. /// <summary>
  17. /// Called when the model should be stopped and data and events should closed.
  18. /// </summary>
  19. void OnStop();
  20. /// <summary>
  21. /// Restores the state of the model from the provide cache. Must be called after OnStart.
  22. /// </summary>
  23. /// <param name="cache">Cache to read the state from.</param>
  24. void RestoreState([NotNull] IWindowCache cache);
  25. /// <summary>
  26. /// Saves the state of the model into the cache. Must be called before OnStop.
  27. /// </summary>
  28. /// <param name="cache">Cache to save the state into.</param>
  29. void SaveState([NotNull] IWindowCache cache);
  30. }
  31. }