Skip to content

Instantly share code, notes, and snippets.

@intojs
Created November 21, 2020 00:35
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 intojs/04707e4c59eeeb973964de3115652419 to your computer and use it in GitHub Desktop.
Save intojs/04707e4c59eeeb973964de3115652419 to your computer and use it in GitHub Desktop.
React MVC - Model
class Model {
#view;
#counter = 0;
attach(view) {
this.#view = view;
this.#notify();
}
incrementCounter() {
this.#counter += 1;
this.#notify();
}
#notify = () => {
if (this.#view) {
this.#view.update(this.#counter);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment