[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Proposed change to WebGL Event definition

On Aug 26, 2010, at 8:13 PM, Cedric Vivier wrote:

On Thu, Aug 26, 2010 at 23:54, Chris Marrin <cmarrin@apple.com> wrote:
I'm not concerned about this confusion. Status codes are enums, types are strings. The status codes for lost and restored context allow you to have a single handler with a simple switch for handling the codes.
I don't get  your argument, this is exactly the problem.
You can have a single handler with a simple switch on "type" as well ... _javascript_ supports switch on strings.

Status codes are not event types, being able to currently switch on status codes will just break existing code in subtle ways whenever we add new status codes to event types.
Status codes are supposed to give _additional_ status information for a given event type, it should be clear that these are secondary and treating them as first-class "type" just makes things confusing and more fragile in the long term :

Consider :

switch (e.type) {
case "webglcontextlost":


switch (e.statusCode) {

The former code will always work as intended even if we add status code to give more information about the context loss (eg. full vs partial vs temporary  [resource reclaim by browser for another newer tab] vs longterm [suspend], whatever...).

The latter will break existing code if we ever decide to give more information.

Ok, I see your point. I will get rid of the two status codes.