samedi 29 août 2015

Promises as way of controlling state

I would like your comments on the use of promises in a part of my code.

I have a View, lets call it Foo. Foo implements Interface EmbeddableView. I have Foo embedded in view Bar. Foo is unaware that it is embedded anywhere and Bar does not care about the content of Foo, only if it's valid or not. The way this happends is the interface EmbeddableView has a function like getValidationPromise returning a promise.

When view Foo resolves the promise, bar is notified that its content either rendered invalid or valid.

However, that validation state change is not a one time thing. It will jump back and forth. It is no longer a promise on the completion of an operation. It can fail, re-fail, success and maybe fail again. Would you say promises is still a meaningful way of implementing this?

Any comments about how this could be implemented in typescript/javascript in a meaningful way is appreciated.

Aucun commentaire:

Enregistrer un commentaire