Take snapshot before publishing events

I hit a scenario whereby if an event was listened for that also updated
the entity, the snapshot would become incorrect.

Examples assume a snapshot threshold of 1.

The previous behaviour:

    +- Publish FooSet event sets foo=1
    |
    +-+- foo_set listener which results in something that sets foo=2
      |
      +- Save snapshot with foo=2
      |
    +-+- exit listener
    |
    +- Save snapshot with foo=1
    |
    +- Snapshot is now incorrect

By taking the snapshot before publishing the event:

    +- Publish FooSet event sets foo=1
    |
    +- Save snapshot with foo=1
    |
    +-+- foo_set listener which results in something that sets foo=2
      |
      +- Save snapshot with foo=2
      |
    +-+- exit listener
    |
    +- Snapshot is now correct
Merge pull request #17 from adambird/post-snapshot-publish

Take snapshot before publishing events