{"id":6459,"date":"2015-12-26T21:25:19","date_gmt":"2015-12-26T12:25:19","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=6459"},"modified":"2015-12-26T21:25:19","modified_gmt":"2015-12-26T12:25:19","slug":"javascript-node-js-%e9%96%8b%e7%99%ba%e3%81%ab%e4%be%bf%e5%88%a9%ef%bc%81%ef%bc%81-javascript-state-machine-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%be%e3%81%97%e3%81%9f%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=6459","title":{"rendered":"JavaScript \/ Node.js \u958b\u767a\u306b\u4fbf\u5229\uff01\uff01 javascript-state-machine \u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002"},"content":{"rendered":"<p>JavaScript\u3067state\u7ba1\u7406\u3067\u304d\u308b<strong>\u300c\u00a0javascript-state-machine\u300d<\/strong> \u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u30de\u30cb\u30a2\u30c3\u30af\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306a\u308b\u304b\u3082\u77e5\u308c\u307e\u305b\u3093\u304c\u3001JavaScript\u958b\u767a\u3092\u884c\u3046\u65b9\u306b\u306f\u30e1\u30b8\u30e3\u30fc\u306a\u306e\u304b\u3082\u3067\u3059\u306d\u3002<\/p>\n<p><strong>github\u306estar\u30822500<\/strong>\u3092\u8d85\u3048\u3066\u3044\u307e\u3057\u3066\u3001\u660e\u3089\u304b\u306b\u79c1\u304c\u516c\u958b\u3057\u305f<strong>\u300cMessageViewJS\u300d<\/strong>\u3088\u308a\u3082\u4eba\u6c17\u304c\u3042\u308a\u307e\u3059\u306d\uff01w\uff08\u5f53\u305f\u308a\u524d\u304b\u3002\uff09<\/p>\n<p>\u8fd1\u5e74\u3001<strong>node.js\u306a\u3069Javascript\u306e\u767a\u5c55\u306b\u4f34\u3044\u3001\u30d5\u30ed\u30f3\u30c8\u3067\u884c\u3048\u308b\u51e6\u7406\u3082\u62e1\u5927\u3057\u3053\u306e\u8fba\u3082\u8003\u616e<\/strong>\u3059\u308b\u4e8b\u306b\u306a\u3063\u3066\u304d\u3066<\/p>\n<p>\u9700\u8981\u304c\u9ad8\u307e\u3063\u3066\u304d\u3066\u3044\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u3044\u3084\u30fc\u5927\u5909w<\/p>\n<p><strong>github<\/strong><\/p>\n<p><strong>javascript-state-machine<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/jakesgordon\/javascript-state-machine\" target=\"_blank\">https:\/\/github.com\/jakesgordon\/javascript-state-machine<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u300c\u00a0javascript-state-machine\u300d<\/strong> \u3068\u306f\u6240\u8b02UML\u3067\u3044\u3046\u3068\u3053\u308d\u306e\u56f3\u3067\u305d\u306e\u7b87\u6240\u3092\u6271\u3046\u306b\u306f\u3068\u3063\u3066\u304a\u304d\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3082\u305d\u3082UML\u3063\u3066\u306a\u3093\u305e\u3084\u3068\u3044\u3046\u65b9\u306b\u8efd\u304f\u3054\u8aac\u660e\u3092<\/p>\n<p><strong>UML\u306fUnified Modeling Language\u306e\u7565<\/strong>\u3067\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u5206\u6790\u3001<\/p>\n<p>\u8a2d\u8a08\u306b\u304a\u3044\u3066\u30b7\u30b9\u30c6\u30e0\u3092\u30e2\u30c7\u30eb\u5316\u3059\u308b\u969b\u306e\u8a18\u6cd5(\u56f3\u6cd5)\u3092\u898f\u5b9a\u3057\u305f<b>\u7d71\u4e00\u30e2\u30c7\u30ea\u30f3\u30b0\u8a00\u8a9e<\/b>(\u30d3\u30b8\u30e5\u30a2\u30eb\u30fb\u30e9\u30f3 \u30b2\u30fc\u30b8)\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e00\u822c\u306eWeb\u30b5\u30a4\u30c8\u3084\u3001Web\u30b5\u30fc\u30d3\u30b9\u3067\u306f\u306a\u304b\u306a\u304b\u7528\u3044\u308b\u6a5f\u4f1a\u3082\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001<\/p>\n<p><strong>\u5927\u898f\u6a21\u306a\u30b7\u30b9\u30c6\u30e0\u958b\u767a\u3084\u3001\u30b2\u30fc\u30e0\u306e\u3088\u3046\u306a\u8907\u96d1\u306a\u8a2d\u8a08\u3001\u4ed5\u69d8<\/strong>\u306b\u306f\u5fc5\u8981\u4e0d\u53ef\u6b20\u3068\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u3068\u3001\u56f3\u3092\u307f\u308c\u3070<strong>\u300c\u3042\u3041\u3002\u307f\u305f\u3053\u3068\u3042\u308b\u3002\u300d<\/strong>\u3068\u8a00\u3046\u65b9\u3082\u3044\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3088\u304f\u898b\u308b\u306e\u306f\u3053\u306e\u3088\u3046\u306a\u00a0<strong>\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u56f3(activity diagram)<\/strong>\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<h5>\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u56f3(activity diagram)<\/h5>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2_04.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2_04.gif\" alt=\"2_04\" width=\"328\" height=\"426\" class=\"alignnone  wp-image-6460\" \/><\/a><\/p>\n<p><strong>\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u56f3(activity diagram)<\/strong>\u306f\u3001\u696d\u52d9\u3084\u51e6\u7406\u306e\u6d41\u308c\u3092\u8868\u3059\u305f\u3081\u306b\u3001<\/p>\n<p>\u95a2\u9023\u3059\u308b\u8907\u6570\u306e\u696d\u52d9\u624b\u9806\u3084\u51e6\u7406\u30b9\u30c6\u30c3\u30d7\u3092\u9806\u5e8f\u3060\u3066\u3066\u914d\u7f6e\u3057\u305f\u3082\u306e\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>UML\u306e\u632f\u308b\u821e\u3044\u56f3\u306b\u5206\u985e\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><strong>JavaScript\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u3001UI\u51e6\u7406\u306a\u3069\u3067\u3082\u4f7f\u7528\u3055\u308c\u308b<\/strong>\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u3053\u3061\u3089\u306f\u79c1\u3082\u3088\u304f\u66f8\u3044\u3066\u307e\u3059\u3002<\/p>\n<h5>\u30af\u30e9\u30b9\u56f3(class diagram)<\/h5>\n<p>\u305d\u306e\u4ed6\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3067\u8a2d\u8a08\u3059\u308b\u5834\u5408\u306a\u3069\u306f\u3001<strong>\u30af\u30e9\u30b9\u56f3(class diagram)<\/strong>\u3092\u5229\u7528\u3059\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/Class.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/Class.png\" alt=\"Class\" width=\"402\" height=\"241\" class=\"alignnone  wp-image-6461\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/Class.png 719w, https:\/\/www.webcyou.com\/wp-content\/uploads\/Class-300x180.png 300w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/a><\/p>\n<p><strong>\u30af\u30e9\u30b9\u56f3(class diagram)\u3067\u306f\u3001\u30e2\u30c7\u30eb\u306e\u9759\u7684\u306a\u69cb\u9020\u3092\u8868\u3059\u56f3\u3067\u3001\u554f\u984c\u9818\u57df\u3084\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u9020\u3092\u8868\u73fe<\/strong>\u3067\u304d\u307e\u3059<\/p>\n<p><strong>ECMAScript6<\/strong>\u3067\u306f\u3001TypeScript\u3084CoffeeScript\u306a\u3069\u306e\u6240\u8b02AltJS\u3082\u7528\u3044\u308b\u4e8b\u3082\u306a\u304f\u3001<\/p>\n<p><strong>class\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059<\/strong>\u306e\u3067\u3001JavaScript\u3092\u66f8\u304b\u308c\u308b\u65b9\u306f<\/p>\n<p>\u5fc5\u7136\u7684\u306b\u3053\u306e\u90e8\u5206\u306f\u7406\u89e3\u3057\u3066\u304a\u304b\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3067\u3057\u3087\u3046\u3002UML\u306e\u69cb\u9020\u56f3\u306b\u5206\u985e\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3068\u3001\u8272\u3005\u66f8\u3044\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u3044\u3088\u3044\u3088\u672c\u984c\u306e\u4ef6\u3068\u306a\u308b\u306e\u3067\u3059\u304c\u3001<\/p>\n<p>UML\u3067\u3044\u3046<strong>\u72b6\u614b\u56f3(statechart diagram)<\/strong>\u304c\u4eca\u56de\u306e\u4ef6\u306b\u3042\u305f\u308a\u307e\u3059\u3002<\/p>\n<h5>\u72b6\u614b\u56f3(statechart diagram)<\/h5>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/Statemachine2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/Statemachine2.png\" alt=\"Statemachine2\" width=\"422\" height=\"301\" class=\"alignnone  wp-image-6462\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/Statemachine2.png 660w, https:\/\/www.webcyou.com\/wp-content\/uploads\/Statemachine2-300x214.png 300w\" sizes=\"auto, (max-width: 422px) 100vw, 422px\" \/><\/a><\/p>\n<p><strong>\u3072\u3068\u3064\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u72b6\u614b\u5909\u5316\u3092\u8868\u3057\u305f\u56f3<\/strong>\u3067\u3001\u5916\u90e8\u304b\u3089\u306e\u5165\u529b\u3068\u3001 \u305d\u308c\u306b\u5bfe\u3059\u308b<strong>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u72b6\u614b\u9077\u79fb<\/strong>\u3092\u8868\u3057\u307e\u3059\u3002<\/p>\n<p>\u3068\u3001UML\u306b\u95a2\u3057\u3066\u3059\u3054\u304f\u565b\u307f\u7815\u3044\u3066\u66f8\u3044\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u89e6\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h4>javascript-state-machine<\/h4>\n<p><strong>github<\/strong><\/p>\n<p><strong>javascript-state-machine<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/jakesgordon\/javascript-state-machine\" target=\"_blank\">https:\/\/github.com\/jakesgordon\/javascript-state-machine<\/a><\/p>\n<p><strong>git clone<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">git clone https:\/\/github.com\/jakesgordon\/javascript-state-machine.git<\/pre>\n<p>git clone\u3092\u884c\u3046\u3068\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u76f4\u4e0b\u306bindex.html\u304c\u5b58\u5728\u3059\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001<\/p>\n<p>\u305d\u3061\u3089\u3092\u30d6\u30e9\u30a6\u30b6\u3067\u958b\u304f\u3068demo\u3092\u52d5\u304b\u3059\u4e8b\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/37de7f0ed6baa797e6f423d7eb23e9f1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/37de7f0ed6baa797e6f423d7eb23e9f1.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-12-26 19.32.21\" width=\"455\" height=\"367\" class=\"alignnone size-full wp-image-6463\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/37de7f0ed6baa797e6f423d7eb23e9f1.png 455w, https:\/\/www.webcyou.com\/wp-content\/uploads\/37de7f0ed6baa797e6f423d7eb23e9f1-300x242.png 300w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>\u3053\u306e\u30c7\u30e2\u306fDemo class\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u3066\u3001<\/p>\n<p>Demo class\u306b\u306f\u3001<strong>\u300cclear\u300d\u300ccalm\u300d\u300cwarm\u300d\u300cpanic!\u300d<\/strong>\u306e<strong>4\u3064\u306e\u30a4\u30d9\u30f3\u30c8<\/strong>\u304c\u3042\u308a<\/p>\n<p><strong>\u300cgreen\u300d\u300cyellow\u300d\u300cred\u300d<\/strong>\u306e3\u3064\u306e\u72b6\u614b\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u72b6\u614b\u9077\u79fb\u3092\u884c\u3046\u306e\u304cjavascript-state-machine\u306e\u5f79\u5272\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u65e9\u901f\u3001demo\u306e\u30bd\u30fc\u30b9\u3092\u78ba\u8a8d\u3059\u308b\u3068<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">var fsm = StateMachine.create({\r\n\u7701\u7565...\r\nevents: &#x5B;\r\n    { name: 'start', from: 'none', to: 'green' },\r\n    { name: 'warn', from: 'green', to: 'yellow' },\r\n    { name: 'panic', from: 'green', to: 'red' },\r\n    { name: 'panic', from: 'yellow', to: 'red' },\r\n    { name: 'calm', from: 'red', to: 'yellow' },\r\n    { name: 'clear', from: 'red', to: 'green' },\r\n    { name: 'clear', from: 'yellow', to: 'green' },\r\n],<\/pre>\n<p>event\u306e\u767b\u9332\u306f\u3053\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u305d\u308c\u305e\u308c<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{ name:\u00a0\u30a4\u30d9\u30f3\u30c8\u540d, from: \u72b6\u614b\u9077\u79fb\u524d, to: \u72b6\u614b\u9077\u79fb\u5f8c },<\/pre>\n<p>\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306bfsm\u306f\u3001<strong>\u6709\u9650\u30aa\u30fc\u30c8\u30de\u30c8\u30f3\uff08FSM\uff1aFinite State Machine\uff09<\/strong>\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>warn\u30a4\u30d9\u30f3\u30c8\u306f\u3001green\u306e\u307f\u3067yellow\u3078\u3068\u72b6\u614b\u9077\u79fb\u3057\u307e\u3059\u3002<\/p>\n<p>panic\u30a4\u30d9\u30f3\u30c8\u306f\u3001green\u3001yellow\u304b\u3089red\u3078\u3068\u72b6\u614b\u9077\u79fb\u3057\u307e\u3059\u3002<\/p>\n<p>calm\u30a4\u30d9\u30f3\u30c8\u306f\u3001red\u306e\u307f\u3067\u3001yellow\u3078\u3068\u72b6\u614b\u9077\u79fb\u3057\u307e\u3059\u3002<\/p>\n<p>clear\u30a4\u30d9\u30f3\u30c8\u306f\u3001red\u3001yellow\u304b\u3089green\u3078\u3068\u72b6\u614b\u9077\u79fb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u69d8\u306b\u3001\u72b6\u614b\u9077\u79fb\u3092\u5236\u9650\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u5f37\u5236\u7684\u306bgreen\u304b\u3089clear\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u706b\u3055\u305b\u3088\u3046\u3068\u3057\u3066\u3082\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Demo.clear();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/7bd0064b0f8aa4477ed2c98aa829bf2c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/7bd0064b0f8aa4477ed2c98aa829bf2c.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-12-26 19.46.07\" width=\"340\" height=\"45\" class=\"alignnone size-full wp-image-6464\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/7bd0064b0f8aa4477ed2c98aa829bf2c.png 340w, https:\/\/www.webcyou.com\/wp-content\/uploads\/7bd0064b0f8aa4477ed2c98aa829bf2c-300x40.png 300w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/><\/a><\/p>\n<p>\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u73fe\u5728\u306e\u72b6\u614b\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u300ccurrent\u300d\u3067\u53c2\u7167\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">fsm.current<\/pre>\n<p>\u307e\u305f\u3001\u72b6\u614b\u9077\u79fb\u304c\u884c\u3048\u308b\u304b\u306e\u5224\u5b9a\u306f\u300ccannot\u300d\u3067\u884c\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">fsm.cannot('panic');<\/pre>\n<p>\u623b\u308a\u5024\u306fboolean\u3067\u3001\u884c\u3048\u308b\u5834\u5408\u306f\u300cfalse\u300d\u51fa\u6765\u306a\u3044\u5834\u5408\u306f\u300ctrue\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h5>Callbacks<\/h5>\n<p>\u305d\u306e\u4ed6\u3001callback\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">callbacks: {\r\n    onbeforestart: function(event, from, to) { log(\"STARTING UP\"); },\r\n    onstart: function(event, from, to) { log(\"READY\"); },\r\n    \r\n    onbeforewarn: function(event, from, to) { log(\"START EVENT: warn!\", true); },\r\n    onbeforepanic: function(event, from, to) { log(\"START EVENT: panic!\", true); },\r\n    onbeforecalm: function(event, from, to) { log(\"START EVENT: calm!\", true); },\r\n    onbeforeclear: function(event, from, to) { log(\"START EVENT: clear!\", true); },\r\n...\u7701\u7565\r\n}<\/pre>\n<p>\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306e4\u7a2e\u985e\u306f\u3001\u6b21\u306e\u547d\u540d\u898f\u5247\u3092\u4f7f\u7528\u3057\u3066\u3001\u30b9\u30c6\u30fc\u30c8\u30de\u30b7\u30f3\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u53d6\u308a\u4ed8\u3051\u308b\u3053\u3068\u3067\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30fbonbeforeEVENT- event \u767a\u706b\u524d<\/p>\n<p>\u30fbonleaveSTATE- \u9077\u79fb\u524d\u306e\u72b6\u614b\u304b\u3089\u96e2\u308c\u308b\u969b<\/p>\n<p>\u30fbonenterSTATE- \u72b6\u614b\u9077\u79fb\u5f8c<\/p>\n<p>\u30fbonafterEVENT-\u00a0event \u767a\u706b\u5f8c<\/p>\n<h5>\u7701\u7565\u53ef<\/h5>\n<p>2\u3064\u306ecallback\u306f\u7701\u7565\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30fbonEVENT- onafterEVENT\u306e\u7701\u7565<\/p>\n<p>\u30fbonSTATE- onenterSTATE\u306e\u7701\u7565<\/p>\n<p><strong>\u4f8b\uff1a<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">onpanic: function(event, from, to) { \r\n    log(\"FINISH \u00a0EVENT: panic!\");\r\n},<\/pre>\n<p>\u307e\u305f\u3001 4\u3064\u306e\u6c4e\u7528\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306f\u3001\u3059\u3079\u3066\u306e\u30a4\u30d9\u30f3\u30c8\u3068\u72b6\u614b\u306e\u5909\u66f4\u3092\u30ad\u30e3\u30d7\u30c1\u30e3\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30fbonbeforeevent- \u5168\u3066\u306eevent\u767a\u706b\u524d<\/p>\n<p>\u30fbonleavestate- \u5168\u3066\u306e\u72b6\u614b\u306e\u9077\u79fb\u524d<\/p>\n<p>\u30fbonenterstate-\u5168\u3066\u306e\u72b6\u614b\u306e\u9077\u79fb\u5f8c<\/p>\n<p>\u30fbonafterevent-\u5168\u3066\u306eevent\u767a\u706b\u5f8c<\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">onafterevent: function(event, from, to) {\r\n    console.log('\u5168\u3066\u306eevent \u767a\u706b\u5f8c\u306bcallback');\r\n},<\/pre>\n<h5>callback \u5f15\u6570<\/h5>\n<p>\u3059\u3079\u3066\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306f\u540c\u3058\u5f15\u6570\u304c\u6e21\u3055\u308c\u307e\u3059<br \/>\n\u30fb event  name<br \/>\n\u30fb from  state<br \/>\n\u30fb to  state<\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">onenterstate: function(event, from, to) {\r\n   console.log(event, from, to);\r\n},<\/pre>\n<p>\u3068\u3001\u5f8c\u306f\u516c\u5f0f\u306e\u8aac\u660e\u3092\u898b\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u65b0\u3057\u304f\u9ed2\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>\u9ed2\u3092\u8ffd\u52a0<\/h4>\n<p>events\u306b\u65b0\u3057\u304f&#8217;dark&#8217; event\u3092\u8ffd\u52a0\u3057\u3001\u72b6\u614b\u9077\u79fb\u3067 black\u3078\u3068\u9077\u79fb\u3067\u304d\u308b\u69d8\u306b\u4ee5\u4e0b\u306e\u69d8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">events: &#x5B;\r\n\u7701\u7565..\r\n{ name: 'clear', from: 'black', to: 'green' },\r\n    { name: 'dark', from: 'green', to: 'black' },\r\n    { name: 'dark', from: 'yellow', to: 'black' },\r\n    { name: 'dark', from: 'red', to: 'black' },\r\n]<\/pre>\n<p>HTML\u306e\u65b9\u304b\u3089\u3001dark\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u706b\u3067\u304d\u308b\u69d8\u306b\u8ffd\u52a0\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;button id=&quot;dark&quot; onclick=&quot;Demo.dark();&quot;&gt;dark!&lt;\/button&gt;<\/pre>\n<p>\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001dark\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u706b\u3055\u305b\u308b\u3068\u3001\u3053\u306e\u69d8\u306a\u611f\u3058\u306b<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/c0cc666099a03430996e281802f9362e.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/c0cc666099a03430996e281802f9362e.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-12-26 21.00.46\" width=\"356\" height=\"290\" class=\"alignnone  wp-image-6465\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/c0cc666099a03430996e281802f9362e.png 459w, https:\/\/www.webcyou.com\/wp-content\/uploads\/c0cc666099a03430996e281802f9362e-300x244.png 300w\" sizes=\"auto, (max-width: 356px) 100vw, 356px\" \/><\/a><\/p>\n<p><strong>black\u304b\u3089 clear\u30a4\u30d9\u30f3\u30c8\u306e\u307f\u8d77\u3053\u305b\u308b\u69d8<\/strong>\u306b\u767b\u9332\u3057\u3066\u3044\u308b\u306e\u3067\u3001<strong>\u62bc\u305b\u308b\u30dc\u30bf\u30f3\u3082\u00a0clear\u306e\u307f<\/strong>\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\nclear\u62bc\u3059\u3068\u5143\u3069\u304a\u308a\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2db77757ccca2db838a2f25de771fe9f.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2db77757ccca2db838a2f25de771fe9f.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-12-26 21.01.04\" width=\"392\" height=\"329\" class=\"alignnone  wp-image-6468\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2db77757ccca2db838a2f25de771fe9f.png 438w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2db77757ccca2db838a2f25de771fe9f-300x252.png 300w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/a><br \/>\n\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u3067<br \/>\n<strong>javascript-state-machine<\/strong>\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\n\u901a\u5e38\u306eweb\u30b5\u30a4\u30c8\u3084web\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u308b\u4e0a\u3067\u3001\u89e6\u308c\u308b\u6a5f\u4f1a\u3082\u5c11\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001<br \/>\nJavaScript\u3067\u306e\u5927\u898f\u6a21\u306a\u30b7\u30b9\u30c6\u30e0\u958b\u767a\u3084\u3001\u30b2\u30fc\u30e0\u5236\u4f5c\u3067\u306f\u5fc5\u8981\u3068\u306a\u3063\u3066\u304f\u308b\u8981\u7d20\u3067\u3001<br \/>\n\u73fe\u5728\u3082HTML5\u306b\u3088\u308b\u30b2\u30fc\u30e0\u5236\u4f5c\u306a\u3069\u3082\u518d\u3073\u76db\u308a\u4e0a\u304c\u3063\u3066\u304d\u3066\u3044\u308b\u611f\u3058\u3082\u3042\u3063\u3066\u3001<br \/>\n\u4eca\u5f8c\u6271\u3046\u6a5f\u4f1a\u304c\u5897\u3048\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u3067\u306f\u3067\u306f\u30fc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript\u3067state\u7ba1\u7406\u3067\u304d\u308b\u300c\u00a0javascript-state-machine\u300d \u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u3061\u3087\u3063\u3068\u30de\u30cb\u30a2\u30c3\u30af\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306a\u308b\u304b\u3082\u77e5\u308c\u307e\u305b\u3093\u304c\u3001JavaScript\u958b\u767a\u3092\u884c\u3046\u65b9\u306b\u306f\u30e1\u30b8\u30e3\u30fc\u306a\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[167,177,168,176,40,166,37,47,179,50,46,169,58,44,111,178,64,138,78,114,118],"class_list":["post-6459","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-css","tag-css3","tag-html","tag-html5","tag-ios-sdk","tag-iphone","tag-iphone-","tag-javascript-2","tag-jquery","tag-jquery-mobile","tag-js","tag-mac","tag-sdk","tag-web","tag-wordpress-2","tag-178","tag-64","tag-138","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/6459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6459"}],"version-history":[{"count":1,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/6459\/revisions"}],"predecessor-version":[{"id":6469,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/6459\/revisions\/6469"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}