Created
November 21, 2020 00:35
-
-
Save intojs/04707e4c59eeeb973964de3115652419 to your computer and use it in GitHub Desktop.
React MVC - Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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