Flaredown / FlaredownEmber

Flaredown Ember Application
0 stars 0 forks source link

Groovy Global Response Handler #11

Open theworkerant opened 10 years ago

theworkerant commented 10 years ago

Let's begin this task with an abstract discussion leading to a high level proposed solution. There are many moving parts that this will depend on, for now we can assume they will be implemented separately or in tandem. See examples at the bottom to get an idea of concrete situations this will apply to.

Purpose

The purpose of this task is to unify and make sense of the various ways responses can enter the Ember application. Furthermore, deciding what kind of actions should be taken and how they will be achieved. Much of the important work here will be simply deciding on (and enforcing) the format of the various messages (usually in json) being passed to the app.

A note on I18n

Don't forget we're going to implementing I18n soon on the API side and pass locale information to the Ember side by request. This needs to be taken into account when architecting a solution here.

Behold!

global response handler

A)

What format will errors sent from the api take? Currently there is a makeshift format in place, something like: {"error": {"some_object": "something bad happened"}}. This isn't so bad, but we need to make sure it doesn't miss anything.

Some questions:

I imagine this piece will be the core of whatever code comes out of this task, probably a mixin or something similar. We need to create some sort of library to process a message and make decisions on how it should be displayed by Ember given these sorts of attributes:

Given a particular message, how should it be displayed given the current context and contents of the message? What possible display methods will be supported?

This piece overlaps a lot with E.

D)

There will be certain situations where messages should trigger some sort of action on the Ember side. This will most likely be handled on a case-by-case basis and does not need a "general" implementation, however there should be a spot reserved for this.

E)

This part should mostly deal with naming conventions that can be relied upon when building forms. For example, an error on email field might set another field emailError to true and emailErrorMessage to "Bad email!!".

Assuming a separate piece of code that processes form input and generates success/failure of validation/processing of that form, based on the response object we can:

Like API messages (A), we need to decide on a particular format for Pusher messages and how they will be parsed. These messages normally come from async operations but their content can be anything we want.

G)

Any other sorts of messages/responses we might want to account for?


Examples Scenarios


Sub tasks


From Projectplace Card 2041934 -- https://service.projectplace.com/pp/pp.cgi/1027628928/direct/actions/list/details/2041934

theworkerant commented 10 years ago

Something to keep in mind: http://emberjs.com/guides/routing/loading-and-error-substates/#toc_the-code-error-code-event