Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

'remove' event handling inconsistent with other events #13

Closed
wellcaffeinated opened this issue Aug 7, 2012 · 4 comments
Closed

'remove' event handling inconsistent with other events #13

wellcaffeinated opened this issue Aug 7, 2012 · 4 comments

Comments

@wellcaffeinated
Copy link
Contributor

Remove event handling is inconsistent with the other events. No key name is provided to the event handler for remove actions... making the idea of remove event handling unfortunately useless.

Module.set('key', 'value'); // fires (create, create:key, mutate, mutate:key, change, change:key) events with parameters
Module.set('key', 'othervalue'); // fires (update, update:key, mutate, mutate:key, change, change:key) events with parameters
Module.remove('key'); // fires (remove, change) events without any parameters!

Request that this is changed to:

Module.remove('key'); // to fire (remove, remove:key, mutate, mutate:key, change, change:key) events with appropriate parameters
// such that
Module.on({
    'change': function( v ){
        // v === 'key'
    },
    'change:key': function( v ){
        // v === LAST VALUE
    },
    'mutate': function( v ){
        // v.oldValue === LAST VALUE
        // v.newValue === undefined
        // v.key === 'key'
    },
    'mutate:key': function( v ){
        // v.oldValue === LAST VALUE
        // v.newValue === undefined
        // v.key === 'key'
    },
    'remove': function( v ){
        // v === 'key'
    },
    'remove:key': function( v ){
        // v === LAST VALUE
    }
});
@wellcaffeinated
Copy link
Contributor Author

Submitted pull request to resolve this issue: #14

@hay
Copy link
Owner

hay commented Aug 10, 2012

I agree, remove() needs to throw the same events as set(). However, i think the implementation is a little too complicated, with having an extra parameter to setAttribute(). It makes the code less readable. If you could provide an implementation that is cleaner i would happily include it in the next release of Stapes.

@wellcaffeinated
Copy link
Contributor Author

What would a cleaner version look like? Would you be more agreeable to a .removeAttribute() method?

@hay
Copy link
Owner

hay commented Aug 11, 2012

Yes, i think it would make more sense to have both a remove and setAttribute method.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants