logic-runtime-react-z 3.1.4 → 3.1.5
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/README.md +7 -4
- package/build/logic/createLogic.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,14 +149,17 @@ You have **2 integration styles**:
|
|
|
149
149
|
Keeps view pure and declarative.
|
|
150
150
|
|
|
151
151
|
```tsx
|
|
152
|
+
// full see: LIVE EXAMPLE
|
|
152
153
|
import { withLogic, LogicViewProps } from "logic-runtime-react-z"
|
|
153
154
|
import { counterLogic } from "./counter.logic"
|
|
154
155
|
|
|
156
|
+
interface MyProps {}
|
|
157
|
+
|
|
155
158
|
type CounterInjected =
|
|
156
|
-
LogicViewProps<typeof counterLogic>
|
|
159
|
+
LogicViewProps<typeof counterLogic> & MyProps
|
|
157
160
|
|
|
158
161
|
const CounterView = ({ state, actions, emit }: LogicViewProps) => {
|
|
159
|
-
// actions and emit => same emit
|
|
162
|
+
// actions and emit => same emit (update state)
|
|
160
163
|
return (
|
|
161
164
|
<div>
|
|
162
165
|
<h2>Count: {state.count}</h2>
|
|
@@ -278,7 +281,7 @@ async function run() {
|
|
|
278
281
|
await runtime.emit("login")
|
|
279
282
|
await runtime.emit("logout")
|
|
280
283
|
|
|
281
|
-
console.log(runtime.
|
|
284
|
+
console.log(runtime.state)
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
run()
|
|
@@ -313,7 +316,7 @@ const logic = createLogic({
|
|
|
313
316
|
const runtime = logic.create()
|
|
314
317
|
|
|
315
318
|
await runtime.emit("set", 4)
|
|
316
|
-
expect(runtime.
|
|
319
|
+
expect(runtime.state.squared).toBe(16)
|
|
317
320
|
```
|
|
318
321
|
|
|
319
322
|
---
|
|
@@ -17,7 +17,7 @@ export declare function createLogic<S extends object, C extends ComputedDef<S>,
|
|
|
17
17
|
}) => (...args: any[]) => any>>(config: {
|
|
18
18
|
name?: string;
|
|
19
19
|
state: S;
|
|
20
|
-
computed
|
|
20
|
+
computed?: C;
|
|
21
21
|
intents?: (bus: {
|
|
22
22
|
on: LogicRuntime<S, C, any>["onIntent"];
|
|
23
23
|
effect: (type: string, eff: EffectDef) => void;
|