summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--package.json2
-rw-r--r--src/shapex.ts8
3 files changed, 7 insertions, 7 deletions
diff --git a/README.md b/README.md
index 9ff91b8..0669c12 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Create scalable event-driven applications with ShapeX, inspired by [re-frame](ht
This is an example application that demonstrates how to use the ShapeX library. It has a single starting point event called `request`, which returns an updated state, which changes the `counter`. When that state changes, the subscriber for the `counter` state fires.
```typescript
-import ShapeX from "@shapex/shapex";
+import { ShapeX } from "shapex";
type AppState = {
counter: number;
@@ -51,7 +51,7 @@ npm install shapex
At the core of your application is state. You start by initiating ShapeX with some initial state, like so:
```typescript
-import ShapeX from "@shapex/shapex";
+import { ShapeX } from "shapex";
type AppState = {
counter: number;
diff --git a/package.json b/package.json
index da21e49..61b9d70 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "shapex",
- "version": "2.1.1",
+ "version": "2.1.3",
"description": "A scalable event-driven application framework.",
"author": "Asko Nõmm <asko@nmm.ee> (https://nmm.ee)",
"main": "dist/shapex.cjs",
diff --git a/src/shapex.ts b/src/shapex.ts
index 1bd4b17..4fde18b 100644
--- a/src/shapex.ts
+++ b/src/shapex.ts
@@ -254,7 +254,7 @@ export function ShapeX<T extends object>(initialState: T): ShapeXInstance<T> {
// Updates state, and checks for state changes, and if any changes present,
// fires a dispatch for all the state listeners (if there are any).
- if (typeof response.state !== "undefined") {
+ if (response?.state !== undefined) {
const changes = changedState(_state, response.state);
_state = response.state;
@@ -264,17 +264,17 @@ export function ShapeX<T extends object>(initialState: T): ShapeXInstance<T> {
}
// Dispatches events
- if (response.dispatch) {
+ if (response?.dispatch !== undefined) {
if (isSubscriptionResponseList(response.dispatch)) {
for (const dispatchee of response.dispatch) {
- if (dispatchee.with) {
+ if (dispatchee?.with) {
dispatch(dispatchee.to, dispatchee.with);
} else {
dispatch(dispatchee.to);
}
}
} else {
- if (response.dispatch.with) {
+ if (response.dispatch?.with) {
dispatch(response.dispatch.to, response.dispatch.with);
} else {
dispatch(response.dispatch.to);