15 | Intake data, get the object id's, link them to the name, assign the names to 16 | the instance in the key's value, and save the mapping to the controller 17 |
18 | 19 | | Param | 20 | | ----- | 21 | | data | 22 | -------------------------------------------------------------------------------- /docs/docs/api-reference/EventInstance.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: EventInstance 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | A Plexus Event. This is a trackable event that can be listened to and fired. 8 | 9 | - [EventInstance](#EventInstance) 10 | - [.id](#EventInstance+id) 11 | - [.name](#EventInstance+name) 12 | - [.name](#EventInstance+name) 13 | - [.once(callback)](#EventInstance+once) 14 | - [.on(callback)](#EventInstance+on) 15 | - [.emit(payload)](#EventInstance+emit) 16 | - [.disable(disable)](#EventInstance+disable) 17 | 18 | 19 | 20 | ### .id 21 | 22 |The internal id of the event
23 | 24 | 25 | 26 | ### .name 27 | 28 |
29 | The name of the state (NOTE: set with the .name(name)
function)
30 |
Set the key of the state for enhanced internal tracking
37 | 38 | 39 | 40 | ### .once(callback) 41 | 42 |Listen for an event only once
43 | 44 | | Param | Description | 45 | | -------- | --------------------------------------------------- | 46 | | callback |The function to call when the event is fired
| 47 | 48 | 49 | 50 | ### .on(callback) 51 | 52 |Listen for an event
53 | 54 | | Param | Description | 55 | | -------- | --------------------------------------------------- | 56 | | callback |The function to call when the event is fired
| 57 | 58 | 59 | 60 | ### .emit(payload) 61 | 62 |Broadcast an event to all listeners
63 | 64 | | Param | Description | 65 | | ------- | ------------------------------------------- | 66 | | payload |The payload to send to all listeners
| 67 | 68 | 69 | 70 | ### .disable(disable) 71 | 72 |Turn the Event Manager off/on
73 | 74 | | Param | Type | Default | Description | 75 | | ------- | -------------------- | ----------------- | ------------------------------------------- | 76 | | disable |boolean
| true
| Should this event Engine be disabled
| 77 | -------------------------------------------------------------------------------- /docs/docs/api-reference/PlexusActionHelpers.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: PlexusActionHelpers 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | The action helpers for a defined plexus action 8 | 9 | - [PlexusActionHelpers](#PlexusActionHelpers) 10 | - [.catchError](#PlexusActionHelpers+catchError) 11 | - [.hooks](#PlexusActionHelpers+hooks) 12 | - [.onCatch(handler, useGlobal)](#PlexusActionHelpers+onCatch) 13 | - [.runErrorHandlers()](#PlexusActionHelpers+runErrorHandlers) 14 | - [.ignoreInit()](#PlexusActionHelpers+ignoreInit) 15 | 16 | 17 | 18 | ### .catchError 19 | 20 | **Internal**: Does the helper instance have any errors handlers to handle an error? 21 | 22 | 23 | 24 | ### .hooks 25 | 26 | **Internal**: Eject the external functions object returned to the user in the first argument of the action function 27 | 28 | 29 | 30 | ### .onCatch(handler, useGlobal) 31 | 32 |33 | Add a new error handler for this action. This will catch any errors that occur 34 | during the execution of this action and prevent a crash. 35 |
36 | 37 | | Param | Default | Description | 38 | | --------- | ----------------- | ---------------------------------------------------------------------------------- | 39 | | handler | |A function that will be called when an error occurs; omit to fail silently.
| 40 | | useGlobal |true
| Should the global error handler be used? (default: true)
| 41 | 42 | 43 | 44 | ### .runErrorHandlers() 45 | 46 | **Internal**: Run all available error handlers 47 | 48 | 49 | 50 | ### .ignoreInit() 51 | 52 |Ignore the default halt for preActions
53 | -------------------------------------------------------------------------------- /docs/docs/api-reference/PlexusController.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: PlexusController 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Plexus Controller can be used to create a controller for a module within your plexus core. 8 | Pass an object that can be many layers deep. Each key is the name of a plexus item (state, action, etc) and the value is the instance of the item. 9 | 10 | 11 | 12 | ### .create(data) 13 | 14 |15 | Intake data, get the object id's, link them to the name, assign the names to 16 | the instance in the key's value, and save the mapping to the controller 17 |
18 | 19 | | Param | 20 | | ----- | 21 | | data | 22 | -------------------------------------------------------------------------------- /docs/docs/api-reference/PlexusInstance.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: PlexusInstance 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | - [PlexusInstance](#PlexusInstance) 8 | - [new PlexusInstance()](#new_PlexusInstance_new) 9 | - [.genId()](#PlexusInstance+genId) ⇒string
10 |
11 |
12 |
13 | ### new PlexusInstance()
14 |
15 | 16 | Holds the hash containing a list of InitActions to be executed when the 17 | instance is ready 18 |
19 | 20 | 21 | 22 | ### .genId() ⇒string
23 |
24 | Is this instance ready?
25 | 26 | **Returns**:string
A new unique id (used internally to generate new watchable value keys)
27 | **Internal**: 28 | -------------------------------------------------------------------------------- /docs/docs/api-reference/Plugin.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Plugin 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Create a new PlexusJS plugin 8 | -------------------------------------------------------------------------------- /docs/docs/api-reference/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "API Reference", 3 | "position": 100 4 | } 5 | -------------------------------------------------------------------------------- /docs/docs/api-reference/action.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: action 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Generate a Plexus Action 8 | 9 | 10 | 11 | ## action(fn) ⇒ 12 | 13 |Generate a Plexus Action
14 | 15 | **Returns**:The intended return value of fn, or null if an error is caught
16 | 17 | | Param | Description | 18 | | ----- | ---------------------------------------- | 19 | | fn |The Plexus action function to run
| 20 | 21 | 22 | 23 | ## .action(fn) ⇒ 24 | 25 |Generate a Plexus Action
26 | 27 | **Returns**:The intended return value of fn, or null if an error is caught
28 | 29 | | Param | Description | 30 | | ----- | ---------------------------------------- | 31 | | fn |The Plexus action function to run
| 32 | -------------------------------------------------------------------------------- /docs/docs/api-reference/batch.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: batch 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Run a function. During that function's execution, any state changes will be batched and only applied once the function has finished. 8 | 9 | 10 | 11 | ## batch(fn) 12 | 13 |14 | Run a function. During that function's execution, any state changes will be 15 | batched and only applied once the function has finished. 16 |
17 | 18 | | Param | Description | 19 | | ----- | ------------------------------------- | 20 | | fn |The function to run in a batch
| 21 | 22 | 23 | 24 | ## .batch(fn) 25 | 26 |27 | Run a function. During that function's execution, any state changes will be 28 | batched and only applied once the function has finished. 29 |
30 | 31 | | Param | Description | 32 | | ----- | ------------------------------------- | 33 | | fn |The function to run in a batch
| 34 | 35 | 36 | 37 | ## .batch(fn) 38 | 39 |40 | The batch function allows you to run a series of reactive actions in a single 41 | transaction. If there is already a batch in progress, the function will be 42 | added to the batch and run when the batch is released. 43 |
44 | 45 | | Param | Type | Description | 46 | | ----- | --------------------- | -------------------------- | 47 | | fn |function
| The function to run
| 48 | -------------------------------------------------------------------------------- /docs/docs/api-reference/batchAction.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: batchAction 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Generate a Plexus Action 8 | 9 | 10 | 11 | ## batchAction(fn) ⇒ 12 | 13 |Generate a Plexus Action
14 | 15 | **Returns**:The intended return value of fn, or null if an error is caught
16 | 17 | | Param | Description | 18 | | ----- | ---------------------------------------- | 19 | | fn |The Plexus action function to run
| 20 | 21 | 22 | 23 | ## .batchAction(fn) ⇒ 24 | 25 |Generate a Plexus Action
26 | 27 | **Returns**:The intended return value of fn, or null if an error is caught
28 | 29 | | Param | Description | 30 | | ----- | ---------------------------------------- | 31 | | fn |The Plexus action function to run
| 32 | -------------------------------------------------------------------------------- /docs/docs/api-reference/collection.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: collection 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Create a new Collection Instance 8 | 9 | 10 | 11 | ## collection(config) ⇒ 12 | 13 |Create a new Collection Instance
14 | 15 | **Returns**:A collection Instance
16 | 17 | | Param | Description | 18 | | ------ | ------------------------------------------- | 19 | | config |The configuration for the collection
| 20 | 21 | 22 | 23 | ## .collection(config) ⇒ 24 | 25 |Create a new Collection Instance
26 | 27 | **Returns**:A collection Instance
28 | 29 | | Param | Description | 30 | | ------ | ------------------------------------------- | 31 | | config |The configuration for the collection
| 32 | -------------------------------------------------------------------------------- /docs/docs/api-reference/computed.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: computed 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Generate a Plexus State 8 | 9 | 10 | 11 | ## computed(item) ⇒ 12 | 13 |Generate a Plexus State
14 | 15 | **Returns**:A Plexus State Instance
16 | 17 | | Param | Description | 18 | | ----- | ---------------------------------------------------------- | 19 | | item |The default value to use when we generate the state
| 20 | 21 | 22 | 23 | ## .computed(item) ⇒ 24 | 25 |Generate a Plexus State
26 | 27 | **Returns**:A Plexus State Instance
28 | 29 | | Param | Description | 30 | | ----- | ---------------------------------------------------------- | 31 | | item |The default value to use when we generate the state
| 32 | -------------------------------------------------------------------------------- /docs/docs/api-reference/event.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: event 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Create a new event Engine 8 | 9 | 10 | 11 | ## event() ⇒ 12 | 13 |Create a new event Engine
14 | 15 | **Returns**:An Event Instance
16 | 17 | 18 | 19 | ## .event() ⇒ 20 | 21 |Create a new event Engine
22 | 23 | **Returns**:An Event Instance
24 | -------------------------------------------------------------------------------- /docs/docs/api-reference/getInstanceName.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: getInstanceName 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Get the correctly formatted instance name 8 | 9 | 10 | 11 | ## getInstanceName() ⇒ 12 | 13 |Get the correctly formatted instance name
14 | 15 | **Returns**:The formatted name of the instance
16 | -------------------------------------------------------------------------------- /docs/docs/api-reference/getPlexusInstance.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: getPlexusInstance 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Get the reference to the instance with a given name, if no name is provided, the master instance is returned 8 | 9 | 10 | 11 | ## getPlexusInstance(name) ⇒ 12 | 13 |14 | Get the reference to the instance with a given name, if no name is provided, 15 | the master instance is returned 16 |
17 | 18 | **Returns**:If no name, returns the main instance of PlexusJS, otherwise returns the instance with the given name (ex. a plugins instance)
19 | 20 | | Param | Default | Description | 21 | | ----- | -------------------- | ------------------------------------------ | 22 | | name |default
| (optional) The name of the instance
| 23 | -------------------------------------------------------------------------------- /docs/docs/api-reference/getPlexusMasterInstance.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: getPlexusMasterInstance 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Get the master instance 8 | 9 | 10 | 11 | ## getPlexusMasterInstance() ⇒ 12 | 13 |Get the master instance
14 | 15 | **Returns**:The master of PlexusJS; oversees all instances of PlexusJS
16 | -------------------------------------------------------------------------------- /docs/docs/api-reference/gql.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: gql 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Simple GraphQL query builder. 8 | 9 | 10 | 11 | ## gql(chunks, ...variables) ⇒string
12 |
13 | Simple GraphQL query builder.
14 | 15 | **Returns**:string
The built query
16 | **Todo** 17 | 18 | - [ ] Improve type safety 19 | - [ ] Make this work better 20 | 21 | | Param | Type | Description | 22 | | ------------ | --------------------------------- | ------------------------------------------------------ | 23 | | chunks |TemplateStringsArray
| The template string chunks
| 24 | | ...variables |Array.<any>
| The variables to be interpolated into the query
| 25 | 26 | 27 | 28 | ## .gql(query, variables) ⇒Promise.<PlexusApiRes.<unknown>>
29 |
30 | Send a graphql request
31 | 32 | **Returns**:Promise.<PlexusApiRes.<unknown>>
The response from the server
33 | 34 | | Param | Type | Description | 35 | | --------- | --------------------------------------- | ---------------------------- | 36 | | query |string
| The gql query to send
| 37 | | variables |Record.<string, any>
| Variables
| 38 | -------------------------------------------------------------------------------- /docs/docs/api-reference/instance.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: instance 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Generate a new instance (or pull the existing instance) of PlexusJS 8 | 9 | 10 | 11 | ## instance(config) ⇒ 12 | 13 |Generate a new instance (or pull the existing instance) of PlexusJS
14 | 15 | **Returns**:An instance of PlexusJS
16 | 17 | | Param | Description | 18 | | ------ | ----------------------------------------- | 19 | | config |The configuration for the instance
| 20 | -------------------------------------------------------------------------------- /docs/docs/api-reference/onCatch.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: onCatch 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Add a new error handler for this action. This will catch any errors that occur during the execution of this action and prevent a crash. 8 | 9 | 10 | 11 | ## onCatch(handler?) 12 | 13 |14 | Add a new error handler for this action. This will catch any errors that occur 15 | during the execution of this action and prevent a crash. 16 |
17 | 18 | | Param | Description | 19 | | -------- | ---------------------------------------------------------------------------------- | 20 | | handler? |A function that will be called when an error occurs; omit to fail silently.
| 21 | 22 | 23 | 24 | ## .onCatch(handler, useGlobal) 25 | 26 |27 | Add a new error handler for this action. This will catch any errors that occur 28 | during the execution of this action and prevent a crash. 29 |
30 | 31 | | Param | Default | Description | 32 | | --------- | ----------------- | ---------------------------------------------------------------------------------- | 33 | | handler | |A function that will be called when an error occurs; omit to fail silently.
| 34 | | useGlobal |true
| Should the global error handler be used? (default: true)
| 35 | -------------------------------------------------------------------------------- /docs/docs/api-reference/preaction.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: preaction 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Generate a Plexus Action 8 | 9 | 10 | 11 | ## preaction(fn) ⇒ 12 | 13 |Generate a Plexus Action
14 | 15 | **Returns**:The intended return value of fn, or null if an error is caught
16 | 17 | | Param | Description | 18 | | ----- | ---------------------------------------- | 19 | | fn |The Plexus action function to run
| 20 | 21 | 22 | 23 | ## .preaction(fn) ⇒ 24 | 25 |Generate a Plexus Action
26 | 27 | **Returns**:The intended return value of fn, or null if an error is caught
28 | 29 | | Param | Description | 30 | | ----- | ---------------------------------------- | 31 | | fn |The Plexus action function to run
| 32 | -------------------------------------------------------------------------------- /docs/docs/api-reference/state.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: state 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Generate a Plexus State 8 | 9 | 10 | 11 | ## state(item) ⇒ 12 | 13 |Generate a Plexus State
14 | 15 | **Returns**:A Plexus State Instance
16 | 17 | | Param | Description | 18 | | ----- | ---------------------------------------------------------- | 19 | | item |The default value to use when we generate the state
| 20 | 21 | 22 | 23 | ## .state(item) ⇒ 24 | 25 |Generate a Plexus State
26 | 27 | **Returns**:A Plexus State Instance
28 | 29 | | Param | Description | 30 | | ----- | ---------------------------------------------------------- | 31 | | item |The default value to use when we generate the state
| 32 | -------------------------------------------------------------------------------- /docs/docs/api-reference/storage.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: storage 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | Create a new Storage Instance 8 | 9 | 10 | 11 | ## storage(name, override) ⇒ 12 | 13 |Create a new Storage Instance
14 | 15 | **Returns**:A storage instance
16 | 17 | | Param | Description | 18 | | -------- | ------------------------------------------------------------------------------------------ | 19 | | name |The name of the Storage Module
| 20 | | override |The function overrides for the Storage Module, if omitted, defaults to localStorage
| 21 | -------------------------------------------------------------------------------- /docs/docs/api-reference/usePlexus.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: usePlexus 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | A React hook to extract the values from plexus objects and reactively update the component and value when the values change 8 | 9 | 10 | 11 | ## usePlexus(deps) ⇒ 12 | 13 |14 | A React hook to extract the values from plexus objects and reactively update 15 | the component and value when the values change 16 |
17 | 18 | **Returns**:The reactive values of the plexus objects
19 | 20 | | Param | Description | 21 | | ----- | -------------------------------------------------------------------------------- | 22 | | deps |A list of plexus watchable objects (ex. State, Group, Selector, Computed)
| 23 | -------------------------------------------------------------------------------- /docs/docs/api-reference/usePlexusState.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: usePlexusState 3 | --- 4 | 5 | [](https://www.npmjs.org/package/@plexusjs/core) 6 | 7 | A React hook to extract the values from plexus objects and reactively update the component and value when the value changes. This hook returns an array, similar to that of React's useState. The arguments are similar to useState as well, it returns the current value and a function to update the value. 8 | 9 | 10 | 11 | ## usePlexusState(dep) ⇒ 12 | 13 |14 | A React hook to extract the values from plexus objects and reactively update 15 | the component and value when the value changes. This hook returns an array, 16 | similar to that of React's useState. The arguments are similar to useState as 17 | well, it returns the current value and a function to update the value. 18 |
19 | 20 | **Returns**:[currentValue, Function] The current value and a function to update the value
21 | 22 | | Param | Description | 23 | | ----- | ------------------------------------- | 24 | | dep |The Plexus dependency to watch
| 25 | -------------------------------------------------------------------------------- /docs/docs/getting-started/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Getting Started", 3 | "position": 20 4 | } 5 | -------------------------------------------------------------------------------- /docs/docs/getting-started/concepts.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Concepts 3 | sidebar_position: 10 4 | --- 5 | 6 | ## Strategy 7 | 8 | We designed Plexus to take the business logic away from the components; this essentially turns your components into puppets for Plexus to orchestrate. Keeping business log seprate has many benifits, including versitility. 9 | 10 | ## Structure 11 | 12 | Plexus was designed to be completely unopinionated on how to structure your app. You can technically place our functions anywhere, but we have several style guides you can follow if you don't know where to start. We are also working on an NPX script to set up and edit a Plexus core, update to newer versionsof Plexus, and get lists of files/components using a core module! 13 | 14 | ## Internal Terms 15 | 16 |Constructor Function (CF):
The{' '}
19 | functions you import from our package. You use these to{' '}
20 |
21 | create Instances.
22 |
23 | Stateful:
A reactive variable that can be
26 | subscribed to and updated.
27 | Instance:
Something that is{' '}
30 | connected to the plexus "network".
31 | Module:
The optional objects where you{' '}
34 |
35 | merge all your instances together
36 |
37 | , structured however you want!
38 | Core:
The optional object where you{' '}
41 |
42 | merge all your instances and/or modules together
43 |
44 | , structured however you want!
45 | {description}
21 |> = P extends Promise<
68 | infer T
69 | >
70 | ? T
71 | : never
72 |
73 | declare type StateFromFunctionReturningPromise<
74 | T extends FunctionReturningPromise,
75 | > = AsyncState
3 |
4 |
19 |
20 | {{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/params/params-table.hbs:
--------------------------------------------------------------------------------
1 | {{#if params}}
2 |
3 | {{tableHead params "name|Param" "type|Type" "defaultvalue|Default" "description|Description" ~}}
4 |
5 | {{#tableRow params "name" "type" "defaultvalue" "description" ~}}
6 | | {{#if @col1}}{{>param-table-name}} | {{/if~}}
7 | {{#if @col2}}{{>linked-type-list types=type.names delimiter=" \| " }} | {{/if~}}
8 | {{#if @col3}}{{>defaultvalue}} | {{/if~}}
9 | {{#if @col4}}{{{stripNewlines (inlineLinks description)}}} |{{/if}}
10 | {{/tableRow}}
11 |
12 | {{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/params/params.hbs:
--------------------------------------------------------------------------------
1 | {{#if (optionEquals "param-list-format" "list")}}{{>params-list~}}{{/if~}}
2 | {{#if (optionEquals "param-list-format" "table")~}}
3 | {{#if (optionEquals "no-gfm" true)}}{{>params-table-html~}}{{else}}{{>params-table~}}{{/if~}}
4 | {{/if~}}
5 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/properties/properties-list.hbs:
--------------------------------------------------------------------------------
1 | {{#if properties}}**Properties**
2 |
3 | {{#each properties~}}
4 | {{#if (regexp-test name "\w+\.\w+")}} {{/if}}- {{{name}}} {{>linked-type-list types=type.names delimiter=" \| " ~}}{{#if description}} - {{{inlineLinks description}}}{{/if}}
5 | {{/each}}
6 |
7 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/properties/properties-table-html.hbs:
--------------------------------------------------------------------------------
1 | {{#if properties~}}**Properties**
2 |
3 |
5 | {{#each (tableHeadHtml params "name|Param" "type|Type" "defaultvalue|Default" "description|Description")}}
7 |
8 |
9 | {{#tableRow params "name" "type" "defaultvalue" "description" ~}}
10 | {{this}} {{/each}}
6 |
11 | {{#if @col1}}
16 | {{~/tableRow}}
17 |
18 | {{>param-table-name}} {{/if~}}
12 | {{#if @col2}}{{>linked-type-list types=type.names delimiter=" | " html=true}} {{/if~}}
13 | {{#if @col3}}{{>defaultvalue}} {{/if~}}
14 | {{#if @col4}}{{{md (inlineLinks description)}}} {{/if}}
15 |
4 |
5 |
20 |
21 | {{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/properties/properties-table.hbs:
--------------------------------------------------------------------------------
1 | {{#if properties}}**Properties**
2 |
3 | {{tableHead properties "name|Name" "type|Type" "defaultvalue|Default" "description|Description" ~}}
4 |
5 | {{#tableRow properties "name" "type" "defaultvalue" "description" ~}}
6 | | {{#if @col1}}{{>param-table-name}} | {{/if~}}
7 | {{#if @col2}}{{>linked-type-list types=type.names delimiter=" \| " }} | {{/if~}}
8 | {{#if @col3}}{{>defaultvalue}} | {{/if~}}
9 | {{#if @col4}}{{{stripNewlines (inlineLinks description)}}} |{{/if}}
10 | {{/tableRow}}
11 |
12 | {{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/properties/properties.hbs:
--------------------------------------------------------------------------------
1 | {{#if (optionEquals "property-list-format" "list")}}{{>properties-list~}}{{/if~}}
2 | {{#if (optionEquals "property-list-format" "table")~}}
3 | {{#if (optionEquals "no-gfm" true)}}{{>properties-table-html}}{{else}}{{>properties-table}}{{/if~}}
4 | {{/if~}}
5 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/readOnly.hbs:
--------------------------------------------------------------------------------
1 | {{#if readonly}}**Read only**: true
2 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/requires.hbs:
--------------------------------------------------------------------------------
1 | {{#if requires~}}
2 | **Requires**: {{>linked-type-list types=requires delimiter=", " }}
3 | {{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/returns.hbs:
--------------------------------------------------------------------------------
1 | {{#if returns}}
2 | {{#if returns.[0].description~}}
3 | **Returns**: {{#each returns~}}
4 | {{#if type~}}
5 | {{#if type.names}}{{>linked-type-list types=type.names delimiter=" \| " ~}}{{/if}}
6 | {{~#if description}} {{{inlineLinks description}}}{{/if~}}
7 | {{else~}}
8 | {{{inlineLinks description}~}}
9 | {{/if~}}
10 | {{~/each}}
11 |
12 | {{/if}}{{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/scope.hbs:
--------------------------------------------------------------------------------
1 | {{#if scope}}
2 | **Kind**: {{#if (equal kind "event") ~}}
3 | event emitted{{#if memberof}} by {{>link to=memberof}}{{/if}}
4 | {{else~}}
5 | {{scope}} {{#if virtual}}abstract {{/if}}{{kindInThisContext}}{{#if memberof}} of {{>link to=memberof}}{{/if}}
6 | {{/if~}}
7 | {{else~}}
8 | {{#if isExported}}**Kind**: Exported {{kind}}
9 | {{/if~}}
10 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/see.hbs:
--------------------------------------------------------------------------------
1 | {{#if see~}}
2 |
3 | {{#if (equal see.length 1)~}}
4 | **See**: {{{inlineLinks see.[0]}}}
5 | {{else~}}
6 | **See**
7 |
8 | {{#each see}}- {{{inlineLinks this}}}
9 | {{/each}}
10 |
11 | {{/if~}}
12 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/since.hbs:
--------------------------------------------------------------------------------
1 | {{#if since}}**Since**: {{{inlineLinks since}}}
2 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/summary.hbs:
--------------------------------------------------------------------------------
1 | {{#if summary}}**Summary**: {{{inlineLinks summary}}}
2 | {{/if~}}
3 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/this.hbs:
--------------------------------------------------------------------------------
1 | {{#if thisvalue}}**this**: {{>link to=thisvalue}}
2 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/throws.hbs:
--------------------------------------------------------------------------------
1 | {{#if exceptions~}}
2 | **Throws**:
3 |
4 | {{#each exceptions~}}
5 | - {{#if type.names}}{{>linked-type-list types=type.names}} {{/if}}{{{inlineLinks description}}}
6 | {{/each}}
7 |
8 | {{/if}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/todo.hbs:
--------------------------------------------------------------------------------
1 | {{#if todoList~}}
2 | **Todo**
3 |
4 | {{#if (option "no-gfm")~}}
5 |
6 | {{#each todoList~}}
7 | {{#if done}}- {{{inlineLinks task}}} ✓
8 | {{else}}- {{{inlineLinks task}}}
9 | {{/if~}}
10 | {{/each~}}
11 |
12 | {{else~}}
13 |
14 | {{#each todoList~}}
15 | {{#if done}}- [x] {{{inlineLinks task}}}
16 | {{else}}- [ ] {{{inlineLinks task}}}
17 | {{/if~}}
18 | {{/each~}}
19 |
20 | {{/if}}
21 |
22 | {{/if~}}
23 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/body/version.hbs:
--------------------------------------------------------------------------------
1 | {{#if version}}**Version**: {{inlineLinks version}}
2 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/docs.hbs:
--------------------------------------------------------------------------------
1 | {{>header~}}
2 | {{>body}}
3 | {{>member-index~}}
4 | {{>separator~}}
5 | {{>members~}}
6 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/header.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{>heading-indent}}{{>sig-name}}
4 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/member-index/member-index-grouped.hbs:
--------------------------------------------------------------------------------
1 | {{string-repeat " " (add level baseLevel)}}* {{#unless (equal _title undefined)}}_{{_title}}_{{else}}{{>sig-link}}{{/unless}}
2 | {{#groupBy (option "group-by")~}}
3 | {{>member-index-grouped baseLevel=(add ../level ../baseLevel 1)~}}
4 | {{/groupBy~}}
5 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/member-index/member-index-list.hbs:
--------------------------------------------------------------------------------
1 | {{>index-indent}}* {{>sig-link-parent}}
2 | {{#indexChildren ~}}
3 | {{>member-index-list~}}
4 | {{/indexChildren}}
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/member-index/member-index.hbs:
--------------------------------------------------------------------------------
1 | {{setLevel this 0~}}
2 | {{#if (descendants min=(option 'memberIndex.minDescendants'))~}}
3 | {{#if isExported~}}
4 | {{#if (equal (depth) 0)}}
5 | {{#if (optionEquals "member-index-format" "list")}}
6 |
7 | {{>member-index-list}}
8 |
9 | {{else~}}
10 |
11 | {{>member-index-grouped}}
12 |
13 | {{/if~}}
14 | {{/if~}}
15 | {{else~}}
16 | {{#if (optionEquals "member-index-format" "list")}}
17 |
18 | {{>member-index-list}}
19 |
20 | {{else}}
21 |
22 | {{>member-index-grouped}}
23 |
24 | {{/if~}}
25 | {{/if~}}
26 | {{/if}}
27 |
--------------------------------------------------------------------------------
/scripts/templates/all-docs/docs/members.hbs:
--------------------------------------------------------------------------------
1 | {{#children inherited=undefined ~}}
2 | {{>docs~}}
3 | {{/children~}}
4 |
--------------------------------------------------------------------------------
/scripts/templates/fn.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | title: ${name}
3 | ---
4 |
5 | [](https://www.npmjs.org/package/@plexusjs/core)
6 |
7 | ${description}
8 |
9 | {{#functions name="${identifierKey}"}}
10 | {{>member-index~}}
11 | {{>separator~}}
12 | {{>members~}}
13 | {{>docs}}
14 | {{/functions}}
--------------------------------------------------------------------------------
/scripts/templates/main-index/global-index/global-index-dl.hbs:
--------------------------------------------------------------------------------
1 | {{#globals kind=kind ~}}
2 | {{#if @first~}}{{>heading-indent}}{{../title}}
3 |
4 |
6 | {{#each (tableHeadHtml properties "name|Name" "type|Type" "defaultvalue|Default" "description|Description")}}
8 |
9 |
10 | {{#tableRow properties "name" "type" "defaultvalue" "description" ~}}
11 | {{this}} {{/each}}
7 |
12 | {{#if @col1}}
17 | {{~/tableRow}}
18 |
19 | {{>param-table-name}} {{/if~}}
13 | {{#if @col2}}{{>linked-type-list types=type.names delimiter=" | " html=true}} {{/if~}}
14 | {{#if @col3}}{{>defaultvalue}} {{/if~}}
15 | {{#if @col4}}{{{md (inlineLinks description)}}} {{/if}}
16 |
5 | {{/if~}}
6 |
9 |
10 | {{/if~}}
11 | {{/globals~}}
12 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/global-index/global-index-grouped.hbs:
--------------------------------------------------------------------------------
1 | {{#globals kind=kind~}}
2 | {{#if @first~}}{{>heading-indent}}{{../title}}
3 |
4 | {{/if~}}
5 | {{>member-index-grouped~}}
6 | {{#if @last}}
7 |
8 | {{/if~}}
9 | {{/globals}}
10 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/global-index/global-index-kinds.hbs:
--------------------------------------------------------------------------------
1 | {{#unless (optionEquals "global-index-format" "none")~}}
2 | {{#if (optionEquals "global-index-format" "dl")}}
3 | {{>global-index-dl kind=kind title=title ~}}
4 | {{/if~}}
5 | {{#if (optionEquals "global-index-format" "grouped")}}
6 | {{>global-index-grouped kind=kind title=title }}
7 | {{/if~}}
8 | {{#if (optionEquals "global-index-format" "table")}}
9 | {{>global-index-table kind=kind title=title ~}}
10 | {{/if~}}
11 | {{/unless~}}
12 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/global-index/global-index-table.hbs:
--------------------------------------------------------------------------------
1 | {{#globals kind=kind~}}
2 | {{#if @first~}}
3 | {{>heading-indent}}{{../title}}
4 |
5 |
6 |
7 |
20 |
21 | {{/if~}}
22 | {{/globals}}
23 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/global-index/global-index.hbs:
--------------------------------------------------------------------------------
1 | {{>global-index-kinds kind="class" title="Classes" ~}}
2 | {{>global-index-kinds kind="mixin" title="Mixins" ~}}
3 | {{>global-index-kinds kind="member" title="Members" ~}}
4 | {{>global-index-kinds kind="namespace" title="Objects" ~}}
5 | {{>global-index-kinds kind="constant" title="Constants" ~}}
6 | {{>global-index-kinds kind="function" title="Functions" ~}}
7 | {{>global-index-kinds kind="event" title="Events" ~}}
8 | {{>global-index-kinds kind="typedef" title="Typedefs" ~}}
9 | {{>global-index-kinds kind="external" title="External" ~}}
10 | {{>global-index-kinds kind="interface" title="Interfaces" ~}}
11 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/main-index.hbs:
--------------------------------------------------------------------------------
1 | {{! a main index is only shown if at least 2 global or modules exist ~}}
2 |
3 | {{#if (showMainIndex)~}}
4 | {{>module-index~}}
5 | {{>global-index~}}
6 | {{/if~}}
7 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/module-index/module-index-dl.hbs:
--------------------------------------------------------------------------------
1 | {{#modules~}}
2 | {{#if @first~}}{{>heading-indent}}Modules
3 |
4 |
8 |
10 |
11 |
12 | {{/if~}}
13 | Global Description
9 |
14 |
17 | {{#if @last~}}
18 |
19 | {{>sig-link-html}}
15 | {{{md (inlineLinks description)}}}
16 |
5 | {{/if~}}
6 |
9 |
10 | {{/if~}}
11 | {{/modules~}}
12 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/module-index/module-index-grouped.hbs:
--------------------------------------------------------------------------------
1 | {{#modules~}}
2 | {{#if @first~}}{{>heading-indent}}Modules
3 |
4 | {{/if~}}
5 | {{>member-index-grouped~}}
6 | {{/modules}}
7 |
8 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/module-index/module-index-table.hbs:
--------------------------------------------------------------------------------
1 | {{#modules~}}
2 | {{#if @first~}}
3 | {{>heading-indent}}Modules
4 |
5 |
6 |
7 |
20 |
21 | {{/if~}}
22 | {{/modules}}
23 |
--------------------------------------------------------------------------------
/scripts/templates/main-index/module-index/module-index.hbs:
--------------------------------------------------------------------------------
1 | {{#unless (optionEquals "module-index-format" "none")~}}
2 | {{#if (optionEquals "module-index-format" "dl")}}{{>module-index-dl ~}}{{/if~}}
3 | {{#if (optionEquals "module-index-format" "grouped")}}{{>module-index-grouped ~}}{{/if~}}
4 | {{#if (optionEquals "module-index-format" "table")}}{{>module-index-table ~}}{{/if~}}
5 | {{/unless~}}
6 |
--------------------------------------------------------------------------------
/scripts/templates/main.hbs:
--------------------------------------------------------------------------------
1 | {{>main-index~}}
2 | {{>all-docs~}}
3 |
--------------------------------------------------------------------------------
/scripts/templates/ref.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | title: ${name}
3 | ---
4 |
5 | [](https://www.npmjs.org/package/@plexusjs/core)
6 |
7 | ${description}
8 |
9 | {{#class name="${identifierKey}"}}
10 | {{>member-index~}}
11 | {{>separator~}}
12 | {{>members~}}
13 | {{/class}}
--------------------------------------------------------------------------------
/scripts/templates/shared/heading-indent.hbs:
--------------------------------------------------------------------------------
1 | {{string-repeat "#" (headingDepth)}}
--------------------------------------------------------------------------------
/scripts/templates/shared/index-indent.hbs:
--------------------------------------------------------------------------------
1 | {{string-repeat " " (indexDepth)}}
--------------------------------------------------------------------------------
/scripts/templates/shared/separator.hbs:
--------------------------------------------------------------------------------
1 | {{#if (option "separators")~}}
2 | {{#if (option "no-gfm")}}
3 |
4 | * * *
5 |
6 | {{else}}
7 |
8 | ---
9 |
10 | {{/if~}}
11 | {{/if~}}
--------------------------------------------------------------------------------
/scripts/templates/shared/signature/sig-link-html.hbs:
--------------------------------------------------------------------------------
1 | {{#if name}}{{#sig no-gfm=true ~}}
2 | {{{@depOpen}~}}
3 |
4 | {{~{@codeOpen}~}}
5 | {{#if @prefix}}{{@prefix}} {{/if~}}
6 | {{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{name}}}{{/if~}}
7 | {{~#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
8 | {{{@codeClose}~}}
9 |
10 | {{~#if @returnSymbol}} {{@returnSymbol}}{{/if~}}
11 | {{#if @returnTypes}} {{>linked-type-list types=@returnTypes html=true delimiter=" | " }}{{/if~}}
12 | {{#if @suffix}} {{@suffix}}{{/if~}}
13 | {{{@depClose}~}}
14 | {{~/sig}}{{/if~}}
15 |
--------------------------------------------------------------------------------
/scripts/templates/shared/signature/sig-link-parent.hbs:
--------------------------------------------------------------------------------
1 | {{#if name}}{{#sig~}}
2 | {{{@depOpen}~}}
3 | [{{{@codeOpen}~}}
4 | {{#if @prefix}}{{@prefix}} {{/if~}}
5 | {{#if (isClassMember)}}{{@parent~}}{{/if~}}
6 | {{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{name}}}{{/if~}}
7 | {{~#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
8 | {{{@codeClose}}}](#{{{anchorName}}})
9 | {{~#if @returnSymbol}} {{@returnSymbol}}{{/if~}}
10 | {{#if @returnTypes}} {{>linked-type-list types=@returnTypes delimiter=" \| " }}{{/if~}}
11 | {{#if @suffix}} {{@suffix}}{{/if~}}
12 | {{{@depClose}~}}
13 | {{~/sig}}{{/if~}}
14 |
--------------------------------------------------------------------------------
/scripts/templates/shared/signature/sig-link.hbs:
--------------------------------------------------------------------------------
1 | {{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
2 | {{#if name}}{{#sig~}}
3 | {{{@depOpen}~}}
4 | [{{{@codeOpen}~}}
5 | {{#if @prefix}}{{@prefix}} {{/if~}}
6 | {{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{name}}}{{/if~}}
7 | {{~#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
8 | {{{@codeClose}}}](#{{{anchorName}}})
9 | {{~#if @returnSymbol}} {{@returnSymbol}}{{/if~}}
10 | {{#if @returnTypes}} {{>linked-type-list types=@returnTypes delimiter=" \| " }}{{/if~}}
11 | {{#if @suffix}} {{@suffix}}{{/if~}}
12 | {{{@depClose}~}}
13 | {{~/sig}}{{/if~}}
14 | {{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
15 |
--------------------------------------------------------------------------------
/scripts/templates/shared/signature/sig-name.hbs:
--------------------------------------------------------------------------------
1 | {{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
2 | {{#if name}}{{#sig~}}
3 | {{{@depOpen}~}}
4 | {{{@codeOpen}~}}
5 | {{#if @prefix}}{{@prefix}} {{/if~}}
6 | {{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{escape name}}}{{/if~}}
7 | {{#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
8 | {{{@codeClose}~}}
9 | {{#if @returnSymbol}} {{@returnSymbol}}{{/if~}}
10 | {{#if @returnTypes}} {{>linked-type-list types=@returnTypes delimiter=" \| " }}{{/if~}}
11 | {{#if @suffix}} {{@suffix}}{{/if~}}
12 | {{{@depClose}~}}
13 | {{~/sig}}{{/if~}}
14 | {{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
15 |
--------------------------------------------------------------------------------
/scripts/templates/shared/value/defaultvalue.hbs:
--------------------------------------------------------------------------------
1 | {{#unless (equal defaultvalue undefined)}}
8 |
10 |
11 |
12 | {{/if~}}
13 | Module Description
9 |
14 |
17 | {{#if @last~}}
18 |
19 | {{>sig-link-html}}
15 | {{{md (inlineLinks description)}}}
16 | {{#if equals}} = {{/if}}{{#if (equal type.names.[0] "string")}}{{json-stringify defaultvalue}}{{else}}{{defaultvalue}}{{/if}}
{{/unless}}
--------------------------------------------------------------------------------
/scripts/templates/shared/value/link.hbs:
--------------------------------------------------------------------------------
1 | {{! usage: link to="namepath" html=true/false caption="optional caption"~}}
2 |
3 | {{~#if html~}}
4 |
5 |
6 | {{~#link to~}}
7 | {{#if url~}}
8 | {{#if ../../caption}}{{../../../caption}}{{else}}{{name}}{{/if}}
9 | {{~else~}}
10 | {{#if ../../caption}}{{../../../caption}}{{else}}{{name}}{{/if~}}
11 | {{/if~}}
12 | {{/link~}}
13 |
14 |
15 | {{~else~}}
16 |
17 | {{#link to~}}
18 | {{#if url~}}
19 | [{{#if ../../caption}}{{escape ../../../caption}}{{else}}{{escape name}}{{/if}}
]({{{url}}})
20 | {{~else~}}
21 | {{#if ../../caption}}{{escape ../../../caption}}{{else}}{{escape name}}{{/if~}}
22 | {{~/if~}}
23 | {{/link~}}
24 |
25 | {{/if~}}
26 |
--------------------------------------------------------------------------------
/scripts/templates/shared/value/linked-type-list.hbs:
--------------------------------------------------------------------------------
1 | {{#each types~}}
2 | {{>link to=this html=../html ~}}
3 | {{#unless @last}}{{{../delimiter}}}{{/unless~}}
4 | {{/each}}
--------------------------------------------------------------------------------
/tests/controller.test.ts:
--------------------------------------------------------------------------------
1 | import { beforeEach, afterEach, describe, test, expect } from 'vitest'
2 |
3 | import {
4 | batchAction,
5 | instance,
6 | collection,
7 | batch,
8 | action,
9 | computed,
10 | controller,
11 | state,
12 | } from '@plexusjs/core'
13 | import { appointments, users, waitFor } from './test-utils'
14 |
15 | const dummyCollection = collection()
16 | beforeEach(() => {
17 | dummyCollection.clear()
18 | appointments.clear()
19 | users.clear()
20 | })
21 |
22 | describe('Controller Basics', () => {
23 | test('can a controller be used', () => {
24 | const myController = controller('myController', {
25 | myState: state('hey there'),
26 | })
27 | const myModule = myController.module
28 |
29 | expect(myModule.myState).toBeDefined()
30 | expect(myModule.myState.value).toBe('hey there')
31 |
32 | expect(myController.name).toBe('myController')
33 | })
34 | test('can a controller be used with .module', () => {
35 | const myModule = controller({
36 | myState: state('hey there'),
37 | }).module
38 |
39 | expect(myModule.myState).toBeDefined()
40 | expect(myModule.myState.value).toBe('hey there')
41 | })
42 |
43 | test('Can you edit a watchable from a .module call', () => {
44 | const myModule = controller({
45 | myState: state('hey there'),
46 | }).module
47 |
48 | expect(myModule.myState).toBeDefined()
49 | expect(myModule.myState.value).toBe('hey there')
50 | myModule.myState.set('new value')
51 | expect(myModule.myState.value).toBe('new value')
52 | })
53 |
54 | test('Can you edit a collection from a .module call', () => {
55 | const myModule = controller({
56 | myCollection: collection(),
57 | }).module
58 |
59 | expect(myModule.myCollection).toBeDefined()
60 | expect(myModule.myCollection.value).toEqual([])
61 | myModule.myCollection.collect({ id: '1', name: 'test' })
62 | expect(myModule.myCollection.value).toEqual([{ id: '1', name: 'test' }])
63 | expect(myModule.myCollection.name).toBe('myCollection')
64 | })
65 | })
66 |
--------------------------------------------------------------------------------
/tests/engine.test.ts:
--------------------------------------------------------------------------------
1 | // this one is a test of internal systems
2 | import { beforeEach, afterEach, describe, test, expect } from 'vitest'
3 | import { EventEngine } from '@plexusjs/core/src/instance/engine'
4 |
5 | const engine = new EventEngine()
6 | describe('INTERNAL: Engine test', () => {
7 | test('Test adding and removing a listener', () => {
8 | const destroyer = engine.on('jump', (height: number) => {
9 | console.log(`We jumped ${height} meters high!`)
10 | })
11 |
12 | engine.emit('jump', 3)
13 |
14 | destroyer()
15 |
16 | // this shouldn't run the listener
17 | engine.emit('jump', 3)
18 | })
19 | test('Test adding multiple listeners and removing one', () => {
20 | const destroyer = engine.on('jump', (height: number) => {
21 | console.log(`We jumped ${height} meters high!`)
22 | })
23 | const destroyer2 = engine.on('jump', (height: number) => {
24 | console.log(`We jumped ${(height * 3.28084).toFixed(2)} feet high!`)
25 | })
26 |
27 | engine.emit('jump', 3)
28 |
29 | destroyer()
30 |
31 | // this shouldn't run the listener
32 | engine.emit('jump', 3)
33 | })
34 | })
35 |
--------------------------------------------------------------------------------
/tests/event.test.ts:
--------------------------------------------------------------------------------
1 | import { beforeEach, afterEach, describe, test, expect } from 'vitest'
2 | import { event, state } from '@plexusjs/core'
3 |
4 | describe('Testing Event Function', () => {
5 | test('Emitting a string', async () => {
6 | const myEvent = event