diff --git a/AlgebraicDataflowArchitectureModel/models/DataStore.model b/AlgebraicDataflowArchitectureModel/models/DataStore.model index 5aa585c..b31a1b0 100644 --- a/AlgebraicDataflowArchitectureModel/models/DataStore.model +++ b/AlgebraicDataflowArchitectureModel/models/DataStore.model @@ -11,11 +11,13 @@ } channel addTweets { - ref accounts(accounts: Map, addTweets(accounts: Map, tweetId: Str, accountId: Str, contents: Str)) + in accounts(accounts: Map, addTweets(newAccounts: Map, tweetId: Str, accountId: Str, contents: Str)) = newAccounts out tweets(tweets: Map, addTweets(accounts, tweetId, accountId, contents)) - = if(contains(accounts, accountId), + = if( + contains(accounts, accountId), insert(tweets, tweetId, {"accountId": accountId, "contents": contents}), - tweets) + tweets + ) } channel changeTweetsAccountId(tweetId: Str) { diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model b/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model index c3ab4be..4017f0a 100644 --- a/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model +++ b/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model @@ -1,11 +1,10 @@ init { - screen := { - "widgets": { - "001": {"type": "button", "text": "a", "state": 0}, - "002": {"type": "textInput", "text": "", "state": 0} - }, - "layout": true - } + variables := { + "a": { + "from": "001", + "to": "002" + } + } } native channel ScreenUpdate { @@ -32,10 +31,13 @@ out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText } -channel AddButton { - out screen.widgets(widgets: Map, addButton(wid: Str, text: Str)) = insert(widgets, wid, {"type": "button", "text": text, "state": 0}) -} - channel AddTextInput { out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0}) } + +channel ChangeText(wid: Str) { + ref variables.a.from(from, updateText(from, to, newText)) + ref variables.a.to(to, updateText(from, to, nexText)) + in screen.widgets.{wid}.text(curText: Str, updateText(from, to, nexText)) = curText + out screen.widgets.{to}.text(curText: Str, updateText(from, to, nexText)) = if(wid == from, nextText, curText) +}