PatamProject / Patam-BookScrabble

1 stars 0 forks source link

connecting the view model to the model to the view #98

Open mayageva11 opened 1 year ago

mayageva11 commented 1 year ago

In the dynamic connection between the MODEL, VIEWMODEL, and VIEW, the following structure is established:

  1. MODEL to VIEWMODEL:

    • The MODEL contains the game logic and data.
    • The VIEWMODEL is responsible for direct communication with the MODEL and data management operations.
    • The VIEWMODEL includes actions such as data updates, calculations, and adapting the data to the current view configuration.
    • The VIEWMODEL provides functions for the VIEW to read or write data from/to the MODEL.
  2. VIEWMODEL to VIEW:

    • The VIEWMODEL is responsible for dynamically and interactively displaying the data.
    • The VIEW visually presents the information received from the VIEWMODEL to the user.
    • By connecting relevant actions from the VIEW to actions in the VIEWMODEL, users can freely perform actions such as clicking buttons, filling text fields, or any other required action based on the game's requirements.
    • When the VIEW performs an action, such as clicking a button, a scenario is triggered in the VIEWMODEL that allows the process of retrieving new data from the MODEL or sending actions to the server.
  3. VIEW to Server:

    • When an action related to the server is performed (e.g., sending data to the server), the appropriate API should be used to send the request to the server.
    • Communication with the server can be done through communication protocols such as HTTP or WebSocket by sending requests to the server and receiving responses from the server.
    • Communication with the server can be asynchronous, using asynchronous calls or promises, based on the game's requirements.

By establishing this connection, the VIEW can become dynamic, enhancing the user experience. Each user action communicates with the VIEWMODEL, and the effects of these actions are sent back to the VIEW, utilizing the server to maintain data updates.

mayageva11 commented 1 year ago

uri and itay