@dws/muster-devtools-client
v6.7.2
Published
Muster DevTools client
Downloads
35
Readme
@dws/muster-repl
Introduction
A REPL for the Muster library.
Installation
npm install -g @dws/muster-repl@next
Usage
To start the Muster REPL simply run:
muster-repl
Muster REPL supports following commands:
<graph_node>
- evaluate a graph nodesubscribe <graph_node>
- subscribe to a graph nodesub <graph_node>
- alias for thesubscribe
subscribe:<name> <graph_node>
- subscribe to a graph node and name the subscriptionunsubscribe <name>
- remove a named subscriptionunsub <name>
- alias for theunsubscribe
subscriptions
- list all open subscriptions and their valuessubs
- alias for thesubscriptions
load <file_path>
- load an external muster graph
Example REPL queries
Muster version: 5.0.0-rc.6
Muster REPL version: 5.0.0-rc.6
> value('Hello, world')
'value({value: "Hello, world"})'
> computed([value('world')], (name) => `Hello, ${name}`)
'value({value: "Hello, world"})'
> muster({ name: 'Bob' })
'Created a new muster instance.'
> ref('name')
'value({value: "Bob"})'
Open and close subscriptions
Muster version: 5.0.0-rc.6
Muster REPL version: 5.0.0-rc.6
> muster({ name: variable('Bob') })
'Created a new muster instance.'
> subscribe ref('name')
Subscription 1: value({value: "Bob"})
'Subscription "1" opened'
> set('name', 'Jane')
Subscription 1: value({value: "Jane"})
'value({value: "Jane"})'
> unsubscribe 1
'Subscription "1" closed.'
Named subscriptions
Muster version: 5.0.0-rc.6
Muster REPL version: 5.0.0-rc.6
> muster({ name: variable('Bob') })
'Created a new muster instance.'
> subscribe:userName ref('name')
Subscription userName: value({value: "Bob"})
'Subscription "userName" opened'
> unsubscribe userName
'Subscription "userName" closed.'
List open subscriptions
Muster version: 5.0.0-rc.6
Muster REPL version: 5.0.0-rc.6
> subscriptions
'No open subscriptions.'
> subscribe value('asdf')
Subscription 1: value({value: "asdf"})
'Subscription "1" opened'
> subscriptions
ID "1": value('asdf')
Last value: value({value: "asdf"})
undefined
Load external muster graph
Given a graph.js:
module.exports = muster({
firstName: variable('Jane'),
lastName: variable('Doe'),
fullName: computed(
[ref('firstName'), ref('lastName')],
(firstName, lastName) => `${firstName} ${lastName}`,
),
});
You can load that file in REPL:
Muster version: 5.0.0-rc.7
Muster REPL version: 5.0.0-rc.7
> load ~/Desktop/graph.js
Loaded muster instance.
> ref('firstName')
value({value: "Jane"})
> ref('lastName')
value({value: "Doe"})