@kaspernj/api-maker 1.0.123 → 1.0.127

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.
Files changed (58) hide show
  1. package/.eslintrc.js +39 -33
  2. package/__tests__/cable-connection-pool.test.js +4 -4
  3. package/__tests__/custom-error.test.js +13 -0
  4. package/__tests__/model-name.test.js +16 -10
  5. package/__tests__/routes-native.test.js +15 -33
  6. package/__tests__/support/task.js +5 -5
  7. package/__tests__/support/user.js +5 -5
  8. package/index.js +0 -4
  9. package/package.json +6 -5
  10. package/src/api.cjs +15 -15
  11. package/src/base-model.cjs +85 -80
  12. package/src/cable-connection-pool.cjs +11 -11
  13. package/src/cable-subscription-pool.cjs +34 -34
  14. package/src/cable-subscription.cjs +2 -2
  15. package/src/can-can-loader.jsx +7 -7
  16. package/src/can-can.cjs +17 -16
  17. package/src/collection.cjs +36 -36
  18. package/src/command-submit-data.cjs +10 -11
  19. package/src/commands-pool.cjs +13 -13
  20. package/src/custom-error.cjs +20 -14
  21. package/src/deserializer.cjs +7 -7
  22. package/src/devise.cjs +15 -15
  23. package/src/error-logger.cjs +9 -9
  24. package/src/event-connection.jsx +6 -6
  25. package/src/event-created.jsx +8 -8
  26. package/src/event-destroyed.jsx +6 -6
  27. package/src/event-emitter-listener.jsx +6 -6
  28. package/src/event-listener.jsx +8 -8
  29. package/src/event-model-class.jsx +6 -6
  30. package/src/event-updated.jsx +10 -10
  31. package/src/instance-of-class-name.cjs +5 -7
  32. package/src/key-value-store.cjs +21 -18
  33. package/src/logger.cjs +4 -4
  34. package/src/merge.cjs +4 -4
  35. package/src/model-events.cjs +6 -5
  36. package/src/model-name.cjs +6 -5
  37. package/src/model-prop-type.cjs +11 -13
  38. package/src/model-recipes-loader.cjs +4 -4
  39. package/src/model-recipes-model-loader.cjs +45 -15
  40. package/src/models-response-reader.cjs +10 -10
  41. package/src/money-formatter.cjs +11 -11
  42. package/src/params.cjs +7 -7
  43. package/src/preloaded.cjs +6 -6
  44. package/src/resource-route.cjs +14 -12
  45. package/src/resource-routes.jsx +9 -4
  46. package/src/result.cjs +7 -7
  47. package/src/routes-native.cjs +6 -6
  48. package/src/routes.cjs +1 -1
  49. package/src/serializer.cjs +9 -9
  50. package/src/services.cjs +3 -3
  51. package/src/session-status-updater.cjs +14 -14
  52. package/src/source-maps-loader.cjs +11 -11
  53. package/src/translated-collections.cjs +2 -1
  54. package/src/updated-attribute.jsx +17 -14
  55. package/src/validation-error.cjs +5 -8
  56. package/src/validation-errors.cjs +16 -16
  57. package/src/event-location-changed.jsx +0 -21
  58. package/src/history-listener.jsx +0 -20
@@ -9,7 +9,7 @@ const ValidationError = require("./validation-error.cjs")
9
9
  const {ValidationErrors} = require("./validation-errors.cjs")
10
10
 
11
11
  module.exports = class ApiMakerCommandsPool {
12
- static addCommand(data, args = {}) {
12
+ static addCommand (data, args = {}) {
13
13
  let pool
14
14
 
15
15
  if (args.instant) {
@@ -29,7 +29,7 @@ module.exports = class ApiMakerCommandsPool {
29
29
  return promiseResult
30
30
  }
31
31
 
32
- static current() {
32
+ static current () {
33
33
  if (!global.currentApiMakerCommandsPool) {
34
34
  global.currentApiMakerCommandsPool = new ApiMakerCommandsPool()
35
35
  }
@@ -37,11 +37,11 @@ module.exports = class ApiMakerCommandsPool {
37
37
  return global.currentApiMakerCommandsPool
38
38
  }
39
39
 
40
- static flush() {
40
+ static flush () {
41
41
  ApiMakerCommandsPool.current().flush()
42
42
  }
43
43
 
44
- constructor() {
44
+ constructor () {
45
45
  this.flushCount = 0
46
46
  this.pool = {}
47
47
  this.poolData = {}
@@ -49,7 +49,7 @@ module.exports = class ApiMakerCommandsPool {
49
49
  this.globalRequestData = null
50
50
  }
51
51
 
52
- addCommand(data) {
52
+ addCommand (data) {
53
53
  return new Promise((resolve, reject) => {
54
54
  const id = this.currentId
55
55
  this.currentId += 1
@@ -85,11 +85,11 @@ module.exports = class ApiMakerCommandsPool {
85
85
  })
86
86
  }
87
87
 
88
- commandsCount() {
88
+ commandsCount () {
89
89
  return Object.keys(this.pool)
90
90
  }
91
91
 
92
- async flush() {
92
+ async flush () {
93
93
  if (this.commandsCount() == 0) {
94
94
  return
95
95
  }
@@ -120,10 +120,10 @@ module.exports = class ApiMakerCommandsPool {
120
120
  response = await Api.requestLocal({path: url, method: "POST", data: commandSubmitData.getJsonData()})
121
121
  }
122
122
 
123
- for(const commandId in response.responses) {
123
+ for (const commandId in response.responses) {
124
124
  const commandResponse = response.responses[commandId]
125
125
  const commandResponseData = Deserializer.parse(commandResponse.data)
126
- const commandData = currentPool[parseInt(commandId)]
126
+ const commandData = currentPool[parseInt(commandId, 10)]
127
127
  const responseType = commandResponse.type
128
128
 
129
129
  if (commandResponseData) {
@@ -149,7 +149,7 @@ module.exports = class ApiMakerCommandsPool {
149
149
  }
150
150
  }
151
151
 
152
- handleFailedResponse(commandData, commandResponseData) {
152
+ handleFailedResponse (commandData, commandResponseData) {
153
153
  let error
154
154
 
155
155
  if (commandResponseData.error_type == "validation_error") {
@@ -165,13 +165,13 @@ module.exports = class ApiMakerCommandsPool {
165
165
  commandData.reject(error)
166
166
  }
167
167
 
168
- clearTimeout() {
168
+ clearTimeout () {
169
169
  if (this.flushTimeout) {
170
170
  clearTimeout(this.flushTimeout)
171
171
  }
172
172
  }
173
173
 
174
- isActive() {
174
+ isActive () {
175
175
  if (this.commandsCount() > 0) {
176
176
  return true
177
177
  }
@@ -183,7 +183,7 @@ module.exports = class ApiMakerCommandsPool {
183
183
  return false
184
184
  }
185
185
 
186
- setFlushTimeout() {
186
+ setFlushTimeout () {
187
187
  this.clearTimeout()
188
188
  this.flushTimeout = setTimeout(() => this.flush(), 0)
189
189
  }
@@ -1,22 +1,26 @@
1
1
  const {dig, digg} = require("diggerize")
2
2
 
3
- function errorMessages(args) {
4
- return digg(args, "response", "errors").map((error) => {
5
- if (typeof error == "string") {
6
- return error
7
- }
3
+ const errorMessages = (args) => {
4
+ if (typeof args.response == "object") {
5
+ return digg(args, "response", "errors").map((error) => {
6
+ if (typeof error == "string") {
7
+ return error
8
+ }
8
9
 
9
- return digg(error, "message")
10
- })
10
+ return digg(error, "message")
11
+ })
12
+ }
11
13
  }
12
14
 
13
15
  module.exports = class CustomError extends Error {
14
- constructor(message, args = {}) {
15
- if (dig(args, "response", "errors")) {
16
- message = `${message}: ${errorMessages(args).join(". ")}`
16
+ constructor (message, args = {}) {
17
+ let messageToUse = message
18
+
19
+ if (typeof args.response == "object" && dig(args, "response", "errors")) {
20
+ messageToUse = `${messageToUse}: ${errorMessages(args).join(". ")}`
17
21
  }
18
22
 
19
- super(message)
23
+ super(messageToUse)
20
24
  this.args = args
21
25
 
22
26
  // Maintains proper stack trace for where our error was thrown (only available on V8)
@@ -24,11 +28,13 @@ module.exports = class CustomError extends Error {
24
28
  Error.captureStackTrace(this, CustomError)
25
29
  }
26
30
 
27
- errorMessages() {
31
+ errorMessages () {
28
32
  return errorMessages(this.args)
29
33
  }
30
34
 
31
- errorTypes() {
32
- return digg(this, "args", "response", "errors").map((error) => digg(error, "type"))
35
+ errorTypes () {
36
+ if (typeof this.args.response == "object") {
37
+ return digg(this, "args", "response", "errors").map((error) => digg(error, "type"))
38
+ }
33
39
  }
34
40
  }
@@ -3,9 +3,9 @@ const inflection = require("inflection")
3
3
  const Money = require("js-money")
4
4
 
5
5
  module.exports = class ApiMakerDeserializer {
6
- static parse(object) {
6
+ static parse (object) {
7
7
  if (Array.isArray(object)) {
8
- return object.map(value => ApiMakerDeserializer.parse(value))
8
+ return object.map((value) => ApiMakerDeserializer.parse(value))
9
9
  } else if (object && typeof object == "object") {
10
10
  if (object.api_maker_type == "date" || object.api_maker_type == "time") {
11
11
  const date = new Date(digg(object, "value"))
@@ -18,20 +18,20 @@ module.exports = class ApiMakerDeserializer {
18
18
  return Money.fromInteger(cents, currency)
19
19
  } else if (object.api_maker_type == "model") {
20
20
  const modelClassName = inflection.classify(digg(object, "model_name"))
21
- const modelClass = digg(require("@kaspernj/api-maker/src/models"), modelClassName)
21
+ const ModelClass = digg(require("@kaspernj/api-maker/src/models"), modelClassName)
22
22
  const data = ApiMakerDeserializer.parse(digg(object, "serialized"))
23
- const model = new modelClass({data, isNewRecord: false})
23
+ const model = new ModelClass({data, isNewRecord: false})
24
24
 
25
25
  return model
26
26
  } else if (object.api_maker_type == "resource") {
27
27
  const modelClassName = inflection.classify(digg(object, "name"))
28
- const modelClass = digg(require("@kaspernj/api-maker/src/models"), modelClassName)
28
+ const ModelClass = digg(require("@kaspernj/api-maker/src/models"), modelClassName)
29
29
 
30
- return modelClass
30
+ return ModelClass
31
31
  } else {
32
32
  const newObject = {}
33
33
 
34
- for(const key in object) {
34
+ for (const key in object) {
35
35
  const value = object[key]
36
36
  newObject[key] = ApiMakerDeserializer.parse(value)
37
37
  }
package/src/devise.cjs CHANGED
@@ -6,18 +6,18 @@ const inflection = require("inflection")
6
6
  const Services = require("./services.cjs")
7
7
 
8
8
  module.exports = class ApiMakerDevise {
9
- static callSignOutEvent(args) {
9
+ static callSignOutEvent (args) {
10
10
  ApiMakerDevise.events().emit("onDeviseSignOut", {args})
11
11
  }
12
12
 
13
- static current() {
13
+ static current () {
14
14
  if (!global.currentApiMakerDevise)
15
15
  global.currentApiMakerDevise = new ApiMakerDevise()
16
16
 
17
17
  return global.currentApiMakerDevise
18
18
  }
19
19
 
20
- static events() {
20
+ static events () {
21
21
  if (!global.apiMakerDeviseEvents) {
22
22
  global.apiMakerDeviseEvents = new EventEmitter()
23
23
  global.apiMakerDeviseEvents.setMaxListeners(1000)
@@ -26,16 +26,16 @@ module.exports = class ApiMakerDevise {
26
26
  return global.apiMakerDeviseEvents
27
27
  }
28
28
 
29
- static addUserScope(scope) {
29
+ static addUserScope (scope) {
30
30
  const currentMethodName = `current${inflection.camelize(scope)}`
31
31
 
32
- ApiMakerDevise[currentMethodName] = function() {
32
+ ApiMakerDevise[currentMethodName] = function () {
33
33
  return ApiMakerDevise.current().getCurrentScope(scope)
34
34
  }
35
35
 
36
36
  const isSignedInMethodName = `is${inflection.camelize(scope)}SignedIn`
37
37
 
38
- ApiMakerDevise[isSignedInMethodName] = function() {
38
+ ApiMakerDevise[isSignedInMethodName] = function () {
39
39
  if (ApiMakerDevise.current().getCurrentScope(scope)) {
40
40
  return true
41
41
  }
@@ -44,7 +44,7 @@ module.exports = class ApiMakerDevise {
44
44
  }
45
45
  }
46
46
 
47
- static async signIn(username, password, args = {}) {
47
+ static async signIn (username, password, args = {}) {
48
48
  if (!args.scope)
49
49
  args.scope = "user"
50
50
 
@@ -61,18 +61,18 @@ module.exports = class ApiMakerDevise {
61
61
  return {model: modelInstance, response}
62
62
  }
63
63
 
64
- static updateSession(model) {
64
+ static updateSession (model) {
65
65
  const scope = digg(model.modelClassData(), "name")
66
66
  const camelizedScopeName = inflection.camelize(scope, true)
67
67
 
68
68
  ApiMakerDevise.current().currents[camelizedScopeName] = model
69
69
  }
70
70
 
71
- static setSignedOut(args) {
71
+ static setSignedOut (args) {
72
72
  ApiMakerDevise.current().currents[inflection.camelize(args.scope, true)] = null
73
73
  }
74
74
 
75
- static async signOut(args = {}) {
75
+ static async signOut (args = {}) {
76
76
  if (!args.scope)
77
77
  args.scope = "user"
78
78
 
@@ -91,26 +91,26 @@ module.exports = class ApiMakerDevise {
91
91
  return response
92
92
  }
93
93
 
94
- constructor() {
94
+ constructor () {
95
95
  this.currents = {}
96
96
  }
97
97
 
98
- getCurrentScope(scope) {
98
+ getCurrentScope (scope) {
99
99
  if (!(scope in this.currents))
100
100
  this.currents[scope] = this.loadCurrentScope(scope)
101
101
 
102
102
  return this.currents[scope]
103
103
  }
104
104
 
105
- loadCurrentScope(scope) {
105
+ loadCurrentScope (scope) {
106
106
  const scopeData = global.apiMakerDeviseCurrent[scope]
107
107
 
108
108
  if (!scopeData)
109
109
  return null
110
110
 
111
111
  const parsedScopeData = Deserializer.parse(scopeData)
112
- const modelClass = digg(require("@kaspernj/api-maker/src/models"), inflection.camelize(scope))
113
- const modelInstance = new modelClass({data: parsedScopeData})
112
+ const ModelClass = digg(require("@kaspernj/api-maker/src/models"), inflection.camelize(scope))
113
+ const modelInstance = new ModelClass({data: parsedScopeData})
114
114
 
115
115
  return modelInstance
116
116
  }
@@ -1,7 +1,7 @@
1
1
  const SourceMapsLoader = require("./source-maps-loader.cjs")
2
2
 
3
3
  module.exports = class ErrorLogger {
4
- constructor() {
4
+ constructor () {
5
5
  this.errors = []
6
6
  this.sourceMapsLoader = new SourceMapsLoader()
7
7
  this.sourceMapsLoader.loadSourceMapsForScriptTags((script) => {
@@ -14,16 +14,16 @@ module.exports = class ErrorLogger {
14
14
  })
15
15
  }
16
16
 
17
- enable() {
17
+ enable () {
18
18
  this.connectOnError()
19
19
  this.connectUnhandledRejection()
20
20
  }
21
21
 
22
- getErrors() {
22
+ getErrors () {
23
23
  return this.errors
24
24
  }
25
25
 
26
- connectOnError() {
26
+ connectOnError () {
27
27
  global.addEventListener("error", (event) => {
28
28
  if (!this.isHandlingError) {
29
29
  this.isHandlingError = true
@@ -34,7 +34,7 @@ module.exports = class ErrorLogger {
34
34
  })
35
35
  }
36
36
 
37
- connectUnhandledRejection() {
37
+ connectUnhandledRejection () {
38
38
  global.addEventListener("unhandledrejection", (event) => {
39
39
  if (!this.isHandlingError) {
40
40
  this.isHandlingError = true
@@ -45,7 +45,7 @@ module.exports = class ErrorLogger {
45
45
  })
46
46
  }
47
47
 
48
- async onError(event) {
48
+ async onError (event) {
49
49
  await this.sourceMapsLoader.loadSourceMaps()
50
50
 
51
51
  if (event.error && event.error.stack) {
@@ -65,7 +65,7 @@ module.exports = class ErrorLogger {
65
65
  }
66
66
  }
67
67
 
68
- async onUnhandledRejection(event) {
68
+ async onUnhandledRejection (event) {
69
69
  await this.sourceMapsLoader.loadSourceMaps()
70
70
 
71
71
  if (event.reason.stack) {
@@ -85,8 +85,8 @@ module.exports = class ErrorLogger {
85
85
  }
86
86
  }
87
87
 
88
- testPromiseError() {
89
- return new Promise(resolve => {
88
+ testPromiseError () {
89
+ return new Promise((_resolve) => {
90
90
  throw new Error("testPromiseError")
91
91
  })
92
92
  }
@@ -1,6 +1,6 @@
1
1
  const ModelEvents = require("./model-events.cjs")
2
2
  const PropTypes = require("prop-types")
3
- const PropTypesExact = require("prop-types-exact")
3
+ const propTypesExact = require("prop-types-exact")
4
4
  const React = require("react")
5
5
 
6
6
  export default class ApiMakerEventConnection extends React.PureComponent {
@@ -8,28 +8,28 @@ export default class ApiMakerEventConnection extends React.PureComponent {
8
8
  active: true
9
9
  }
10
10
 
11
- static propTypes = PropTypesExact({
11
+ static propTypes = propTypesExact({
12
12
  active: PropTypes.bool.isRequired,
13
13
  model: PropTypes.object.isRequired,
14
14
  event: PropTypes.string.isRequired,
15
15
  onCall: PropTypes.func.isRequired
16
16
  })
17
17
 
18
- componentDidMount() {
18
+ componentDidMount () {
19
19
  this.subscription = ModelEvents.connect(this.props.model, this.props.event, (...args) => this.onCall(...args))
20
20
  }
21
21
 
22
- componentWillUnmount() {
22
+ componentWillUnmount () {
23
23
  if (this.subscription) {
24
24
  this.subscription.unsubscribe()
25
25
  }
26
26
  }
27
27
 
28
- render() {
28
+ render () {
29
29
  return null
30
30
  }
31
31
 
32
- onCall(...args) {
32
+ onCall (...args) {
33
33
  if (this.props.active) {
34
34
  this.props.onCall(...args)
35
35
  }
@@ -1,7 +1,7 @@
1
1
  const debounce = require("debounce")
2
2
  const ModelEvents = require("./model-events.cjs")
3
3
  const PropTypes = require("prop-types")
4
- const PropTypesExact = require("prop-types-exact")
4
+ const propTypesExact = require("prop-types-exact")
5
5
  const React = require("react")
6
6
 
7
7
  export default class ApiMakerEventCreated extends React.PureComponent {
@@ -9,7 +9,7 @@ export default class ApiMakerEventCreated extends React.PureComponent {
9
9
  active: true
10
10
  }
11
11
 
12
- static propTypes = PropTypesExact({
12
+ static propTypes = propTypesExact({
13
13
  active: PropTypes.bool.isRequired,
14
14
  debounce: PropTypes.oneOfType([
15
15
  PropTypes.bool,
@@ -19,21 +19,21 @@ export default class ApiMakerEventCreated extends React.PureComponent {
19
19
  onCreated: PropTypes.func.isRequired
20
20
  })
21
21
 
22
- componentDidMount() {
22
+ componentDidMount () {
23
23
  this.connect()
24
24
  }
25
25
 
26
- componentWillUnmount() {
26
+ componentWillUnmount () {
27
27
  if (this.connectCreated) {
28
28
  this.connectCreated.unsubscribe()
29
29
  }
30
30
  }
31
31
 
32
- connect() {
32
+ connect () {
33
33
  this.connectCreated = ModelEvents.connectCreated(this.props.modelClass, (...args) => this.onCreated(...args))
34
34
  }
35
35
 
36
- debounce() {
36
+ debounce () {
37
37
  if (!this.debounceInstance) {
38
38
  if (typeof this.props.debounce == "number") {
39
39
  this.debounceInstance = debounce(this.props.onCreated, this.props.debounce)
@@ -45,7 +45,7 @@ export default class ApiMakerEventCreated extends React.PureComponent {
45
45
  return this.debounceInstance
46
46
  }
47
47
 
48
- onCreated(...args) {
48
+ onCreated (...args) {
49
49
  if (!this.props.active) {
50
50
  return
51
51
  }
@@ -57,7 +57,7 @@ export default class ApiMakerEventCreated extends React.PureComponent {
57
57
  }
58
58
  }
59
59
 
60
- render() {
60
+ render () {
61
61
  return null
62
62
  }
63
63
  }
@@ -1,29 +1,29 @@
1
1
  const ModelEvents = require("./model-events.cjs")
2
2
  const PropTypes = require("prop-types")
3
- const PropTypesExact = require("prop-types-exact")
3
+ const propTypesExact = require("prop-types-exact")
4
4
  const React = require("react")
5
5
 
6
6
  export default class ApiMakerEventDestroyed extends React.PureComponent {
7
- static propTypes = PropTypesExact({
7
+ static propTypes = propTypesExact({
8
8
  model: PropTypes.object.isRequired,
9
9
  onDestroyed: PropTypes.func.isRequired
10
10
  })
11
11
 
12
- componentDidMount() {
12
+ componentDidMount () {
13
13
  this.connect()
14
14
  }
15
15
 
16
- componentWillUnmount() {
16
+ componentWillUnmount () {
17
17
  if (this.connectDestroyed) {
18
18
  this.connectDestroyed.unsubscribe()
19
19
  }
20
20
  }
21
21
 
22
- connect() {
22
+ connect () {
23
23
  this.connectDestroyed = ModelEvents.connectDestroyed(this.props.model, this.props.onDestroyed)
24
24
  }
25
25
 
26
- render() {
26
+ render () {
27
27
  return null
28
28
  }
29
29
  }
@@ -4,29 +4,29 @@ const React = require("react")
4
4
 
5
5
  export default class ApiMakerEventEmitterListener extends React.PureComponent {
6
6
  static propTypes = {
7
- events: PropTypes.instanceOf(EventEmitter).isRequired,
8
7
  event: PropTypes.string.isRequired,
8
+ events: PropTypes.instanceOf(EventEmitter).isRequired,
9
9
  onCalled: PropTypes.func.isRequired
10
10
  }
11
11
 
12
- constructor(props) {
12
+ constructor (props) {
13
13
  super(props)
14
14
  this.onCalled = this.onCalled.bind(this)
15
15
  }
16
16
 
17
- componentDidMount() {
17
+ componentDidMount () {
18
18
  this.props.events.addListener(this.props.event, this.onCalled)
19
19
  }
20
20
 
21
- componentWillUnmount() {
21
+ componentWillUnmount () {
22
22
  this.props.events.removeListener(this.props.event, this.onCalled)
23
23
  }
24
24
 
25
- onCalled(...args) {
25
+ onCalled (...args) {
26
26
  this.props.onCalled.apply(null, ...args)
27
27
  }
28
28
 
29
- render() {
29
+ render () {
30
30
  return null
31
31
  }
32
32
  }
@@ -1,38 +1,38 @@
1
1
  const PropTypes = require("prop-types")
2
- const PropTypesExact = require("prop-types-exact")
2
+ const propTypesExact = require("prop-types-exact")
3
3
  const React = require("react")
4
4
 
5
5
  export default class ApiMakerEventListener extends React.PureComponent {
6
- static callEvent(target, eventName, args = []) {
6
+ static callEvent (target, eventName, args = []) {
7
7
  let event = document.createEvent("Event")
8
8
  event.initEvent(eventName, false, true)
9
9
  target.dispatchEvent(event, args)
10
10
  }
11
11
 
12
- static propTypes = PropTypesExact({
12
+ static propTypes = propTypesExact({
13
13
  event: PropTypes.string.isRequired,
14
14
  onCalled: PropTypes.func.isRequired,
15
15
  target: PropTypes.object.isRequired
16
16
  })
17
17
 
18
- constructor(props) {
18
+ constructor (props) {
19
19
  super(props)
20
20
  this.onCalled = this.onCalled.bind(this)
21
21
  }
22
22
 
23
- componentDidMount() {
23
+ componentDidMount () {
24
24
  this.props.target.addEventListener(this.props.event, this.onCalled)
25
25
  }
26
26
 
27
- componentWillUnmount() {
27
+ componentWillUnmount () {
28
28
  this.props.target.removeEventListener(this.props.event, this.onCalled)
29
29
  }
30
30
 
31
- onCalled(...args) {
31
+ onCalled (...args) {
32
32
  this.props.onCalled.apply(null, args)
33
33
  }
34
34
 
35
- render() {
35
+ render () {
36
36
  return null
37
37
  }
38
38
  }
@@ -1,30 +1,30 @@
1
1
  const ModelEvents = require("./model-events.cjs")
2
2
  const PropTypes = require("prop-types")
3
- const PropTypesExact = require("prop-types-exact")
3
+ const propTypesExact = require("prop-types-exact")
4
4
  const React = require("react")
5
5
 
6
6
  export default class ApiMakerEventModelClass extends React.PureComponent {
7
- static propTypes = PropTypesExact({
7
+ static propTypes = propTypesExact({
8
8
  event: PropTypes.string.isRequired,
9
9
  modelClass: PropTypes.func.isRequired,
10
10
  onCall: PropTypes.func.isRequired
11
11
  })
12
12
 
13
- componentDidMount() {
13
+ componentDidMount () {
14
14
  this.connect()
15
15
  }
16
16
 
17
- componentWillUnmount() {
17
+ componentWillUnmount () {
18
18
  if (this.connection) {
19
19
  this.connection.unsubscribe()
20
20
  }
21
21
  }
22
22
 
23
- connect() {
23
+ connect () {
24
24
  this.connection = ModelEvents.connectModelClass(this.props.modelClass, this.props.event, this.props.onCall)
25
25
  }
26
26
 
27
- render() {
27
+ render () {
28
28
  return null
29
29
  }
30
30
  }