@kaspernj/api-maker 1.0.315 → 1.0.316
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 +1 -1
- package/src/use-model.mjs +19 -0
package/package.json
CHANGED
package/src/use-model.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {useCallback, useEffect, useState} from "react"
|
|
2
|
+
import Devise from "./devise.mjs"
|
|
2
3
|
import * as inflection from "inflection"
|
|
3
4
|
import ModelEvents from "./model-events.mjs"
|
|
4
5
|
import useQueryParams from "on-location-changed/src/use-query-params.js"
|
|
@@ -120,6 +121,24 @@ const useModel = (modelClassArg, argsArg = {}) => {
|
|
|
120
121
|
}
|
|
121
122
|
}, [args.eventUpdated, model?.id()])
|
|
122
123
|
|
|
124
|
+
const onSignedIn = useCallback(() => {
|
|
125
|
+
loadModel()
|
|
126
|
+
}, [])
|
|
127
|
+
|
|
128
|
+
const onSignedOut = useCallback(() => {
|
|
129
|
+
loadModel()
|
|
130
|
+
}, [])
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
Devise.events().addListener("onDeviseSignIn", onSignedIn)
|
|
134
|
+
Devise.events().addListener("onDeviseSignOut", onSignedOut)
|
|
135
|
+
|
|
136
|
+
return () => {
|
|
137
|
+
Devise.events().removeListener("onDeviseSignIn", onSignedIn)
|
|
138
|
+
Devise.events().removeListener("onDeviseSignOut", onSignedOut)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
|
|
123
142
|
const onDestroyed = useCallback(({model}) => {
|
|
124
143
|
const forwardArgs = {model}
|
|
125
144
|
|