RanvierMUD / core

Core engine code for Ranvier
https://ranviermud.com
MIT License
45 stars 40 forks source link

Metadatable#setMeta now fires an event whenever metadata changes #69

Closed holl0wstar closed 5 years ago

holl0wstar commented 5 years ago

Addresses #66

The only thing I was unsure about is that whenever the metadata doesn't exist, oldVal returns undefined, but I left as is since that could be treated as desired behavior since it's actually undefined.

And excuse the typo.

shawncplus commented 5 years ago

My only comment would be to reverse the new/old param order. The main thing a person cares about when listening for an update is the new value, and then occasionally what the previous value was. So the order should be key, value, oldValue

holl0wstar commented 5 years ago

I re-ordered them.

shawncplus commented 5 years ago

I lied about it being the only comment :P also needs an event doc directly before the emit() call so it'll appear in the online docs

/**
 * @event Metadatable#metadataUpdate
 * @param {string} key
 * @param {*} newValue
 * @param {*} oldValue
 */

And in the function docblock it needs to do @fires Metadatable#metadataUpdate