text: (window.webpackJsonp=window.webpackJsonp||[]).push([[6],{"./packages/ae-docs/pages/State.mdx":function(e,a,n){"use strict";n.r(a),n.d(a,"default",function(){return d});var s=n("./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js"),t=n("./node_modules/@babel/runtime/helpers/esm/classCallCheck.js"),m=n("./node_modules/@babel/runtime/helpers/esm/createClass.js"),o=n("./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js"),p=n("./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js"),c=n("./node_modules/@babel/runtime/helpers/esm/inherits.js"),r=n("./node_modules/react/index.js"),l=n.n(r),N=n("./node_modules/@mdx-js/tag/dist/index.js"),d=function(e){function a(e){var n;return Object(t.a)(this,a),(n=Object(o.a)(this,Object(p.a)(a).call(this,e))).layout=null,n}return Object(c.a)(a,e),Object(m.a)(a,[{key:"render",value:function(){var e=this.props,a=e.components;Object(s.a)(e,["components"]);return l.a.createElement(N.MDXTag,{name:"wrapper",components:a},l.a.createElement(N.MDXTag,{name:"h1",components:a,props:{id:"state-effect"}},"State Effect"),l.a.createElement(N.MDXTag,{name:"p",components:a},"State effect allows you to maintain state accross multiple calls to your program."),l.a.createElement(N.MDXTag,{name:"hr",components:a}),l.a.createElement(N.MDXTag,{name:"h2",components:a,props:{id:"import-it-in-your-project"}},"Import it in your project"),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-js"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { State } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/effects'"),";")),l.a.createElement(N.MDXTag,{name:"h2",components:a,props:{id:"api"}},"API"),l.a.createElement(N.MDXTag,{name:"h3",components:a,props:{id:"with-handler"}},"With handler"),l.a.createElement(N.MDXTag,{name:"ul",components:a},l.a.createElement(N.MDXTag,{name:"li",components:a,parentName:"ul"},l.a.createElement(N.MDXTag,{name:"inlineCode",components:a,parentName:"li"},"State.of"),"\nYou can pass it the initial state for your program and run it.")),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-haskell"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-type"}},"State"),".",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"of")," :: a -> (",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-type"}},"Program"),"<",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-type"}},"State"),"> ...b c, ...b) -> ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-type"}},"Task")," e c")),l.a.createElement(N.MDXTag,{name:"h3",components:a,props:{id:"operations"}},"Operations"),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-js"}},"State = {\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"get"),": func([], ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'a'"),"),\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"set"),": func([",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'a'"),"]),\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"update"),": func([",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'a -> a'"),"], ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'a'"),"),\n}")),l.a.createElement(N.MDXTag,{name:"h2",components:a,props:{id:"usage-examples"}},"Usage examples"),l.a.createElement(N.MDXTag,{name:"h3",components:a,props:{id:"using-state-effect"}},"Using State effect"),l.a.createElement(N.MDXTag,{name:"p",components:a},"State effect allows you to maintain state in your program accross multiple calls."),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-js"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { State } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/effects'"),";\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { call, sleep } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/core/generic'"),";\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," countdown = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-keyword"}},"function"),"*(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}}),") "),"{\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," count = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," State.get();\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"if"),"(count > ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"0"),") {\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," State.set(count - ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"1"),"); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Decrement count"),"\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," sleep(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"1000"),"); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Add a delay of 1 second"),"\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," call(countdown); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Call the function recursively"),"\n  }\n}\n\nState.of(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"10"),")(countdown)\n  .fork(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"()")," =>")," {}, () => alert(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'HAPPY NEW YEAR!!!!'"),"));")),l.a.createElement(N.MDXTag,{name:"h3",components:a,props:{id:"composing-with-state-effect"}},"Composing with State effect"),l.a.createElement(N.MDXTag,{name:"p",components:a},"You can compose State effect with custom effects to make a really cool api"),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-js"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { createEffect } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/core'"),";\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { State } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/effects'"),";\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { call, sleep } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/core/generic'"),";\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," CounterButtonEff = createEffect(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'CounterButtonEff'"),", {\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"takeButtonClick"),": func(),\n});\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," ConsoleEff = createEffect(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'ConsoleEff'"),", {\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"log"),": func([",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'data'"),"]),\n});\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," clickCounter = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-keyword"}},"function"),"*(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}}),") "),"{\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," CounterButtonEff.takeButtonClick();\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," State.update(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"count")," =>")," count + ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"1"),"); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Update the state"),"\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," ConsoleEff.log(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"`Button clicked ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-subst"}},"${",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-keyword"}},"yield")," State.get()}")," times!`"),");\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," call(clickCounter);\n}\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," buttonEff = CounterButtonEff.handler({\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"takeButtonClick"),": ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},"(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"{ resume }"),") =>")," () =>\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-built_in"}},"document"),".getElementById(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'button'"),").addEventListener(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'click'"),", resume),\n});\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," logEff = ConsoleEff.handler({\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"log"),": ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},"(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"{ resume }"),") =>")," data => resume(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-built_in"}},"console"),".log(data)),\n}),\n\nState.of(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"0"),")\n  .with(buttonEff)\n  .with(logEff)\n  .run(clickCounter);")),l.a.createElement(N.MDXTag,{name:"h3",components:a,props:{id:"using-multiple-states"}},"Using Multiple states"),l.a.createElement(N.MDXTag,{name:"p",components:a},"You can have multiple sets of states in your program by ",l.a.createElement(N.MDXTag,{name:"a",components:a,parentName:"p",props:{href:"#core.extend-your-effects"}},"extending")," from State"),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-js"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { State } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/effects'"),";\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"import")," { call, sleep } ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"from")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'@algebraic-effects/core/generic'"),";\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," CountState = State.extendAs(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'CountState'"),");\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," ListState = State.extendAs(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-string"}},"'ListState'"),");\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," countdown = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-keyword"}},"function"),"*(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}}),") "),"{\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," count = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," CountState.get();\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," ListState.update(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"list")," =>")," [...list, count]); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Update list"),"\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"if"),"(count > ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"0"),") {\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," CountState.set(count - ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"1"),"); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Decrement count"),"\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," sleep(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"1000"),"); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Add a delay of 1 second"),"\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," call(countdown); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Call the function recursively"),"\n  }\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"return")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," ListState.get();\n}\n\nState.of(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"10"),", CountState)\n  .with(State.of([], ListState))\n  .run(countdown)\n  .fork(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"()")," =>")," {}, list => {\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-built_in"}},"console"),".log(list); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// 10, 9, 8,...,0"),"\n  });")),l.a.createElement(N.MDXTag,{name:"h3",components:a,props:{id:"using-state-in-multiple-continuations-mode"}},"Using state in multiple continuations mode"),l.a.createElement(N.MDXTag,{name:"p",components:a},"You can use State to maintain program state in multiple continuations mode."),l.a.createElement(N.MDXTag,{name:"p",components:a},l.a.createElement(N.MDXTag,{name:"a",components:a,parentName:"p",props:{href:"#core.multiple-continuations"}},"Read more about it")),l.a.createElement(N.MDXTag,{name:"pre",components:a},l.a.createElement(N.MDXTag,{name:"code",components:a,parentName:"pre",props:{className:"hljs language-js"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," runner = LoopEffect.handler({\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-attr"}},"takeItem"),": ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},"(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"{ resume }"),") =>")," list => list.forEach(resume),\n});\n\n",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-keyword"}},"function")," *",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-title"}},"program"),"(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}}),") "),"{\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," State.set(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"3"),"); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Overwrite initial state"),"\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," item1 = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," LoopEffect.takeItem([ ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"1"),", ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"2")," ]);\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"const")," item2 = ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," LoopEffect.takeItem([ ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"3"),", ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"4")," ]);\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," State.update(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"c")," =>")," c + item1 + item2);\n\n  ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"return")," ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-keyword"}},"yield")," State.get();\n}\n\nrunner\n  .with(State.of(",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"0"),"))\n  .runMulti(program)\n  .fork(\n    ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-function"}},l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"span",props:{className:"hljs-params"}},"()")," =>")," {},\n    sums => {\n      expect(sums).toEqual([",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"7"),", ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"12"),", ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"17"),", ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-number"}},"23"),"]); ",l.a.createElement(N.MDXTag,{name:"span",components:a,parentName:"code",props:{className:"hljs-comment"}},"// Last item is the final state"),"\n    },\n  );")))}}]),a}(l.a.Component)}}]);