Skip to content

Instantly share code, notes, and snippets.

@lauromoura
Created August 5, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lauromoura/72134cf28d47769c67a40a2cf519277b to your computer and use it in GitHub Desktop.
Save lauromoura/72134cf28d47769c67a40a2cf519277b to your computer and use it in GitHub Desktop.
EFL MVVM Notes

EFL MVVM

General MVVM notes

Views

  • Usually just shows stuff on screen
  • Consumes data from ViewModel
  • Bind properties to the ViewModel
    • Two way binding
    • Data on the ViewModel is shown
    • Activations on the View are sent to the ViewModel

ViewModel

  • Implement the properties and commands the View can bind to
  • Notifies the View of state changes through events (IObservable)
  • Coordinate View interaction with Models
  • Can act as a "conversion layer" between the raw Model data and the View
    • For example, combining two Model properties

Model

  • Non visual classes that encapsulate domain's data and business and validation lgic.

Data bindings

  • A run-time decision to connect ViewModels to View
  • View-first composition
    • App composed of Views
    • They connect to the ViewModels they depend on
    • The ViewModels do not have a dependency on the Views themselves
    • More natural way
  • ViewModel-first composition
    • App composed of ViewModels
    • A service locates Views for a given ViewModel
  • Views and ViewModels should be kept independent as much as possible
  • BindingContext
    • Property of BindableObject

MVVM In EFL

Models

  • Efl.Model.eo

    • Interface
    • Store named properties
    • Can have Efl.Objects as children
      • Allows complex hierarchies
    • Emits events
      • properties,changed - Properties become ready or changed values.
      • child,[added,removed] - Child handling
  • Efl.Loop_Model

    • Implements Efl.Model
    • Uses Eo reflection to set properties
    • volatile_make as helper to auto unref childs

Views

  • Efl.Ui.View.eo
    • Single model get/set property

ViewModels

  • Efl.View_Model.eo
    • Extends Efl.Composite_Model
      • Extends Efl.Loop_Model
        • Extends Efl.Loop_Consumer
        • Implements Efl.Model
        • Method volatile_make
          • Registers this model to be deleted if their only ref is their parent's one.
      • Implements Efl.Ui.View
      • Property: Index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment