Comments (2)
There's also quite similar issue with assign statements.
use './utils' { addUser }
action addLoadedUser = assign(user, :addUser)
state idle {
enter => addLoadedUser => loaded
}
state loaded {}
Output:
01 | import { createMachine, assign } from 'xstate';
02 | import { addUser } from './utils'; // Unused variable
03 |
04 | export default function({ context = {} } = {}) {
05 | return createMachine({
06 | context,
07 | states: {
08 | idle: {
09 | on: {
10 | enter: {
11 | target: 'loaded',
12 | actions: ['addLoadedUser']
13 | }
14 | }
15 | },
16 | loaded: {
17 |
18 | }
19 | }
20 | }, {
21 | actions: {
22 | addLoadedUser: assign({
23 | user: assigns.addUser // assigns is not defined
24 | })
25 | }
26 | });
27 | }
I'm likely doing something wrong here, but following the example docs lead to these kind of issues.
from liblucy.
Ah so sorry for not replying before. If you're still interested, the :
means that it is passed in through the machine function. Notice how in the first example it wants you to pass services.getUser
.
To reference the imported method, simply reference it directly, no :
needed:
use './utils' { getUsers }
state idle {
invoke(getUsers) {
done => assign(users)
}
}
from liblucy.
Related Issues (20)
- Allow comments HOT 1
- Allow for stopping spawned actors HOT 5
- Guards for immediate transitions HOT 1
- Allow for unimplemented actions/services/guards HOT 13
- Change the generated code to export a function, not a static machine definition HOT 18
- Add option for outputting to JSON HOT 4
- Add node/browser lib for Lucy HOT 2
- Incorrect indentation when a reference follows an inline assign
- Named actions/guards get shared with sibling machines
- [IDEA] XState JSON to Lucy? HOT 8
- Parallel states
- Nested states without nested machines HOT 2
- Compile hangs if too many repeated event definitions HOT 1
- Actions in nested machines HOT 2
- Target a nested state with an event HOT 2
- spawning should be done with a callback
- dts not created for entry actions
- Sending to an actor should include parent event data
- Why not javascript? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liblucy.