diff --git a/AlgebraicDataflowArchitectureModel/models/DataStore.model b/AlgebraicDataflowArchitectureModel/models/DataStore.model index 7a5c17a..5aa585c 100644 --- a/AlgebraicDataflowArchitectureModel/models/DataStore.model +++ b/AlgebraicDataflowArchitectureModel/models/DataStore.model @@ -1,94 +1,27 @@ -init { - variables := { - "a" : { - "target": "w1", - "source": "a1", - "value": "_" - }, - "b": { - "target": "w3", - "source": "w2", - "value": "_" - } - } - datastore := { - "accounts": { - "a1": "hello" - } - } +channel addAccounts { + out accounts(account: Map, addAccounts(id: Str, name: Str, age: Int)) = insert(accounts, id, {"name": name, "age": age}) } -native channel ScreenUpdate { - in screen(curSc: Json, update(curSc, nextSc)) = nextSc +channel changeAccountsName(id: Str) { + out accounts.{id}.name(name: Str, changeAccountsName(newName: Str)) = newName } -native channel SetLayout { - in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout +channel changeAccountsAge(id: Str) { + out accounts.{id}.name(age: Int, channgeAccountsAge(newAge: Int)) = newAge } -native channel SetVisible(wid: Str) { - in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible +channel addTweets { + ref accounts(accounts: Map, addTweets(accounts: Map, tweetId: Str, accountId: Str, contents: Str)) + out tweets(tweets: Map, addTweets(accounts, tweetId, accountId, contents)) + = if(contains(accounts, accountId), + insert(tweets, tweetId, {"accountId": accountId, "contents": contents}), + tweets) } -native channel SetText(wid: Str) { - in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText +channel changeTweetsAccountId(tweetId: Str) { + out tweets.{tweetId}.accountId(accountId: Str, changeTweetsAccountId(newAccountId: Str)) = newAccountId } -native channel MouseEvent(wid: Str) { - out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState -} - -native channel TextEvent(wid: Str) { - 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 signUp{ - out datastore.accounts(accounts: Map, signUp(id, name)) = insert(accounts, id, name) -} - -channel changeName(aid: Str) { - out datastore.accounts.{aid}(curName: Str, changeName(newName)) = newName -} - -channel setTarget { - out variables.a.target(curTarget: Str, setTarget(newTarget: Str)) = newTarget -} - -channel setSource { - out variables.a.source(curSource: Str, setSource(newSource: str)) = newSource -} - -channel setTargetB { - out variables.b.target(curTarget: Str, setTarget(newTarget: Str)) = newTarget -} - -channel setSourceB { - out variables.b.source(curSource: Str, setSource(newSource: str)) = newSource -} - -channel setValue { - in variables.a.source(curSource: Str, setValue(nextSource, nextName)) = nextSource - in datastore.accounts.{nextSource}(curName, setValue(nextSource, nextName)) = nextName - out variables.a.value(curValue: Str, setValue(nextSource, nextName)) = nextName -} - -channel setButtonText { - in variables.a.target(curTarget: Str, setButtonText(nextTarget, nextText)) = nextTarget - in variables.a.value(curText: Str, setButtonText(nextTarget, nextText)) = nextText - out screen.widgets.{nextTarget}.text(curText, setButtonText(nextTarget, nextText)) = nextText -} - -channel setInputTextValue { - in variables.b.source(curSource: Str, setValue2(nextSource, nextTarget, nextValue)) = nextSource - in variables.b.target(curTarget: Str, setValue2(nextTarget, nextTarget, nextValue)) = nextTarget - in screen.widgets.{nextSource}.text(curValue: Str, setValue2(nextSource, nextTarget, nextValue)) = nextValue - out screen.widgets.{nextTarget}.text(curText, setValue2(nextTarget, nextTarget, nextValue)) = nextValue -} +channel changeTweetsContents(tweetId: Str) { + out tweets.{tweetId}.contents(contents: Str, changeTweetsContents(newContents: Str)) = newContents +} \ No newline at end of file