cryptocoinjs/p2p-manager — pull request #3 by MidnightLightning (2014-01-23 14:52:20+00:00)
Title: State events

| Q | A
| --- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Issues fixed by this | #1

Creates the new functionality suggested in enhancement issue #1; instead of updating the `state` property directly, create an internal method to change the state and emit a `stateChange` event. This update relies on the v0.1.1 patch of [p2p-node](https://github.com/cryptocoinjs/p2p-node), which adds similar functionality to the Peer object.

This new functionality deprecates changing the `state` property on the object directly. To add custom states in an application that uses this module, instead of:

```js
var m = new PeerManager();
m.state = 'fooBar';
```

instead do:

```js
var m = newPeerManager();
m._changeState('fooBar');
```

This is not a binary compatibility break, since you can still update `state` directly, just it won't trigger the new event, which new instances may be waiting for.

# Tasks
- [ ] Changelog updated
- [ ] Usage/Documentation updated
- [ ] Tests pass
- [ ] ACK from other developers