Skip to content

Commit a5f6c2a

Browse files
committed
0.0.23
1 parent 398540d commit a5f6c2a

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

chartlets.js/CHANGES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
## Version 0.0.23 (in development)
1+
## Version 0.0.23 (from 2024/11/19)
2+
3+
* Introduced new interface `HostState` that applications may implement
4+
to provide computed properties, i.e., a derived state. (#43)
25

36
* Replacing entire components if a related component `StateChange`
47
has an empty `property`. (#38)

chartlets.js/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chartlets.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chartlets",
3-
"version": "0.0.22",
3+
"version": "0.0.23",
44
"description": "An experimental library for integrating interactive charts into existing JavaScript applications.",
55
"type": "module",
66
"files": [

chartlets.js/src/demo/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import { getValue, setValue } from "@/lib/utils/objPath";
1111

1212
initializeContributions({
1313
hostStore: {
14+
// Let Chartlets listen to changes in application state.
1415
subscribe: (listener: () => void) => appStore.subscribe(listener),
16+
// Compute a property value and return it. We simply use getValue() here.
1517
get: (property: string): unknown => getValue(appStore.getState(), property),
18+
// Set a property value in the application state.
1619
set: (property: string, value: unknown) =>
1720
void appStore.setState(setValue(appStore.getState(), property, value)),
1821
},

chartlets.js/src/lib/types/state/options.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
import type { ApiOptions } from "@/lib/types/api";
22
import type { LoggingOptions } from "@/lib/actions/helpers/configureLogging";
33

4+
/**
5+
* The host store represents an interface to the state of
6+
* the application that is using Chartlets.
7+
*/
48
export interface HostStore {
9+
/**
10+
* Let Chartlets listen to changes in the host store that may
11+
* cause different values to be returned from the `get()` method.
12+
*
13+
* @param listener A listener that is called when the
14+
* host store changes
15+
*/
516
subscribe: (listener: () => void) => void;
17+
18+
/**
19+
* Get a property value from the host state.
20+
*
21+
* @param property The property name.
22+
* @returns The property value.
23+
*/
624
get: (property: string) => unknown;
25+
26+
/**
27+
* **UNSTABLE API**
28+
*
29+
* Set a property value in the host state.
30+
*
31+
* @param property The property name.
32+
* @param value The new property value.
33+
*/
734
set?: (property: string, value: unknown) => void;
835
}
936

@@ -17,8 +44,12 @@ export function isMutableHostStore(
1744
return !!hostStore && typeof hostStore.set === "function";
1845
}
1946

47+
/**
48+
* Chartlets options to be provided
49+
* by the application that is using Chartlets.
50+
*/
2051
export interface FrameworkOptions {
21-
/** The host application's store. */
52+
/** The host store. */
2253
hostStore?: HostStore;
2354
/** API options to configure backend. */
2455
api?: ApiOptions;

0 commit comments

Comments
 (0)