Skip to content
This repository has been archived by the owner. 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

@wellcaffeinated wellcaffeinated commented Aug 7, 2012

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

@wellcaffeinated wellcaffeinated commented Aug 8, 2012

Submitted pull request to resolve this issue: #14

@hay
Copy link
Owner

@hay 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.

@hay hay closed this Aug 10, 2012
@wellcaffeinated
Copy link
Contributor Author

@wellcaffeinated wellcaffeinated commented Aug 10, 2012

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

@hay
Copy link
Owner

@hay 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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.