move subscriber logic to level above the view
This commit is contained in:
parent
41dd96e9c9
commit
3b9be01cc5
|
@ -2,7 +2,6 @@ import NimQml
|
||||||
import status
|
import status
|
||||||
import libstatus
|
import libstatus
|
||||||
import json
|
import json
|
||||||
import state
|
|
||||||
|
|
||||||
var signalHandler: SignalCallback = proc(p0: cstring): void =
|
var signalHandler: SignalCallback = proc(p0: cstring): void =
|
||||||
setupForeignThreadGc()
|
setupForeignThreadGc()
|
||||||
|
@ -38,18 +37,6 @@ QtObject:
|
||||||
result.accountResult = status.queryAccounts()
|
result.accountResult = status.queryAccounts()
|
||||||
status.subscribeToTest()
|
status.subscribeToTest()
|
||||||
|
|
||||||
var appState = state.newAppState()
|
|
||||||
echo appState.title
|
|
||||||
appState.subscribe(proc () =
|
|
||||||
echo "1nd subscriber got a new update!"
|
|
||||||
for channel in appState.channels:
|
|
||||||
echo channel.name
|
|
||||||
)
|
|
||||||
|
|
||||||
appState.addChannel("test")
|
|
||||||
appState.addChannel("test2")
|
|
||||||
# result.chats.add(ChatView(name: "test"))
|
|
||||||
|
|
||||||
# ¯\_(ツ)_/¯ dunno what is this
|
# ¯\_(ツ)_/¯ dunno what is this
|
||||||
proc setup(self: ApplicationLogic) =
|
proc setup(self: ApplicationLogic) =
|
||||||
# discard status.onMessage(self.onMessage)
|
# discard status.onMessage(self.onMessage)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
import applicationLogic
|
import applicationLogic
|
||||||
import chats
|
import chats
|
||||||
|
import state
|
||||||
|
|
||||||
proc mainProc() =
|
proc mainProc() =
|
||||||
|
|
||||||
|
@ -27,7 +28,19 @@ proc mainProc() =
|
||||||
|
|
||||||
let chatsVariant = newQVariant(chatsModel)
|
let chatsVariant = newQVariant(chatsModel)
|
||||||
defer: chatsVariant.delete
|
defer: chatsVariant.delete
|
||||||
chatsModel.addNameTolist("hello")
|
|
||||||
|
var appState = state.newAppState()
|
||||||
|
echo appState.title
|
||||||
|
|
||||||
|
appState.subscribe(proc () =
|
||||||
|
chatsModel.names = @[]
|
||||||
|
for channel in appState.channels:
|
||||||
|
echo channel.name
|
||||||
|
chatsModel.addNameTolist(channel.name)
|
||||||
|
)
|
||||||
|
|
||||||
|
appState.addChannel("test")
|
||||||
|
appState.addChannel("test2")
|
||||||
|
|
||||||
engine.setRootContextProperty("logic", logicVariant)
|
engine.setRootContextProperty("logic", logicVariant)
|
||||||
engine.setRootContextProperty("chatsModel", chatsVariant)
|
engine.setRootContextProperty("chatsModel", chatsVariant)
|
||||||
|
|
Loading…
Reference in New Issue