yysun / apprun

AppRun is a JavaScript library for developing high-performance and reliable web applications using the elm inspired architecture, events and components.
https://apprun.js.org
MIT License
1.18k stars 58 forks source link

Is there a way to trigger event from console? #98

Closed jkleiser closed 4 years ago

jkleiser commented 4 years ago

This is probably a stupid question, but I'm not sure if and how it can be done. I'm currently working on a new and improved version of a board game (Chinese Checkers) I wrote some years ago. My SPA has a button that lets me (developer) trigger an automatic valid move on the board; the event name is "autoMove". Is it possible for me to fire that event by a command in the console? I have checked Ch. 12 on DevTools in the AppRun book, but I'm not sure if the answer to my question can be found there.

yysun commented 4 years ago

You can just type app.run('autoMove') in the console.

jkleiser commented 4 years ago

I just tried that, but I get "Assertion failed: No subscriber for event: autoMove", with a reference to app.ts 35.

jkleiser commented 4 years ago

I read a little more on page 98 in the book which explained that I had to make my event into a global event. Now I can do app.run('#autoMove') in the console. Thanks.