1

In MVVM (or Presentation Model), my (web) view listens to a CLICK event and calls a function of the Presentation Model to ask for the result.

To clarify, the presentation model lives browser-side. The presentation model then calculates the result asynchronously.

Is it then OK for the Presentation Model to return a (Javascript) promise that the view consumes and updates itself when resolved? (Or is there a reason that I would need to have the view listen to an event from the presentation model and then make a sync call?)

bebbi
  • 361

1 Answers1

-1

MVVM is Model-View-ViewModel

  • Model is the server side representation of the data that your application represents
  • View is the presentation layer the UI - HTML
  • ViewModel is a javascript object that contains the models. The view model is a code abstraction of the UI - HTML and shouldn't have any knowlege of the HTML representation, which allows it to be loosely coupled.

The view model interaction is usually handled using javascript binding frameworks such as Angular and Knockout and is pretty much behind the scenes.

Not sure what technologies you are using but here is a nice example which may help you understand the MVVM architecture using a binding framework, in this case knockout.

http://www.asp.net/web-api/overview/data/using-web-api-with-entity-framework/part-1

"6. Create the JavaScript Client" I think is more what you're after but I'd recommend going through the entire toutorial.