@toa.io/core 1.0.0-alpha.110 → 1.0.0-alpha.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/core",
3
- "version": "1.0.0-alpha.110",
3
+ "version": "1.0.0-alpha.116",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -26,5 +26,5 @@
26
26
  "error-value": "0.3.0",
27
27
  "openspan": "1.0.0-alpha.93"
28
28
  },
29
- "gitHead": "579e0243a9e783d9492c3616d6279f64862305c7"
29
+ "gitHead": "1ff4e4f580295056386cf7fccd5fe323b1f87731"
30
30
  }
package/src/state.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const { empty } = require('@toa.io/generic')
4
3
  const { StatePreconditionException, StateNotFoundException } = require('./exceptions')
5
4
 
6
5
  class State {
@@ -78,18 +77,14 @@ class State {
78
77
  }
79
78
 
80
79
  async commit (state, input) {
81
- const event = state.event(input)
80
+ const object = state.get()
81
+ const ok = await this.storage.store(object)
82
82
 
83
- let ok = true
83
+ // #20
84
+ if (ok === true) {
85
+ const event = state.event(input)
84
86
 
85
- if (!empty(event.changeset)) {
86
- const object = state.get()
87
-
88
- ok = await this.storage.store(object)
89
-
90
- // #20
91
- if (ok === true)
92
- await this.#emission.emit(event)
87
+ await this.#emission.emit(event)
93
88
  }
94
89
 
95
90
  return ok
@@ -38,9 +38,3 @@ it('should emit', async () => {
38
38
 
39
39
  expect(fixtures.emitter.emit).toHaveBeenCalledWith(fixtures.entity.event.mock.results[0].value)
40
40
  })
41
-
42
- it('should not emit if state has not been changed', async () => {
43
- await state.commit(fixtures.unchanged)
44
-
45
- expect(fixtures.emitter.emit).not.toHaveBeenCalled()
46
- })