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
const MVCComponent = () => { | |
const [model, dispatch] = useReducer(reducer, initialModel); | |
const handleEvent = () => { | |
dispatch(action); | |
}; | |
return <View model={model} handleEvent={handleEvent} />; | |
}; |
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
const withValidation = (state, field, value) => { | |
const changedState = { | |
...state, | |
fields: { | |
...state.fields, | |
[field]: { | |
...state.fields[field], | |
value, | |
}, | |
}, |
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
let counter = 0; | |
const count = () => { | |
counter += 1; | |
} |
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 Controller { | |
#model; | |
initialize() { | |
this.#model = new Model(); | |
const view = new View(this.#handleIncrementBtnClick); | |
this.#model.attach(view); | |
} |
NewerOlder