dolittle / Bifrost

This is the stable release of Dolittle till its out of alpha->beta stages
Other
110 stars 32 forks source link

Re-using a command #511

Open smithmx opened 10 years ago

smithmx commented 10 years ago

The MVVM / Single page app requires us to re-use commands. In most cases this will be a command that adds a new instance of something. We should make this easier to do and remove a lot of the coding the front end developer has to do.

  1. We want to be able to how the command can be put into a "new" state. Typically, you want a new commandId (rather than reuse the same one!), you want a new Id created for the entity you are adding, you want any constants set on the command (e.g. if adding a new contact to a supplier, you want the supplierId set).
  2. We want to reset the values silently, so that validation messages do not appear.
einari commented 10 years ago

One thing I’ve been thinking about is the ability to have value providers - not only for commands but for other things like parameters on queries and such. 

Typically you could have a value provider that points to anything, such as a query string parameter in the browser or a factory that gets called to create the value - typically for unique IDs or similar. 

When we fire off the command, we create a copy of the original one anyways, so my guess is that it is for the values that change and a good way for describing the value source.

— Sent from Mailbox

On Mon, Aug 25, 2014 at 9:35 AM, Michael Smith notifications@github.com wrote:

The MVVM / Single page app requires us to re-use commands. In most cases this will be a command that adds a new instance of something. We should make this easier to do and remove a lot of the coding the front end developer has to do.

  1. We want to be able to how the command can be put into a "new" state. Typically, you want a new commandId (rather than reuse the same one!), you want a new Id created for the entity you are adding, you want any constants set on the command (e.g. if adding a new contact to a supplier, you want the supplierId set).

2. We want to reset the values silently, so that validation messages do not appear.

Reply to this email directly or view it on GitHub: https://github.com/dolittle/Bifrost/issues/511

smithmx commented 10 years ago

Yeah, my first thinking was that we have a Init(setup) method where you pass in all the actions you want to be performed when getting a new instance. We first reset everything in the command and then apply the actions provided. I sense you have a more comprehensive approach though... :-)

einari commented 10 years ago

Your senses are right :) I think it could be a less obtrusive one as well, not sure yet..   But the idea is the same. 

Could also be something like

myViewModel: Bifrost.views.ViewModel.extend(function(myCommand) {

   myCommand.someProperty.populatedBy(function...)

   myCommand.someProperty.populatedFrom(.. another observable..);

});

Something like that..  Not sure yet.. 

— Sent from Mailbox

On Mon, Aug 25, 2014 at 9:50 AM, Michael Smith notifications@github.com wrote:

Yeah, my first thinking was that we have a Init(setup) method where you pass in all the actions you want to be performed when getting a new instance. We first reset everything in the command and then apply the actions provided. I sense you have a more comprehensive approach though... :-)

Reply to this email directly or view it on GitHub: https://github.com/dolittle/Bifrost/issues/511#issuecomment-53236705