mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-21 12:01:38 +00:00
Add Changed event
This commit is contained in:
parent
2a25193941
commit
17b2752b38
2 changed files with 17 additions and 9 deletions
|
|
@ -267,10 +267,10 @@ function App:startSession(host: string?, port: string?)
|
|||
end)
|
||||
|
||||
serveSession:onStatusChanged(function(status, details)
|
||||
self.headlessAPI.Connected = status == ServeSession.Status.Connected
|
||||
self.headlessAPI:_updateProperty("Connected", status == ServeSession.Status.Connected)
|
||||
if not self.headlessAPI.Connected then
|
||||
self.headlessAPI.Address = nil
|
||||
self.headlessAPI.ProjectName = nil
|
||||
self.headlessAPI:_updateProperty("Address", nil)
|
||||
self.headlessAPI:_updateProperty("ProjectName", nil)
|
||||
end
|
||||
|
||||
if status == ServeSession.Status.Connecting then
|
||||
|
|
@ -284,8 +284,8 @@ function App:startSession(host: string?, port: string?)
|
|||
elseif status == ServeSession.Status.Connected then
|
||||
local address = string.format("%s:%s", host :: string, port :: string)
|
||||
|
||||
self.headlessAPI.Address = address
|
||||
self.headlessAPI.ProjectName = details
|
||||
self.headlessAPI:_updateProperty("Address", address)
|
||||
self.headlessAPI:_updateProperty("ProjectName", details)
|
||||
|
||||
self:setState({
|
||||
appStatus = AppStatus.Connected,
|
||||
|
|
|
|||
|
|
@ -10,16 +10,20 @@ local API = {}
|
|||
function API.new(app)
|
||||
local Rojo = {}
|
||||
|
||||
Rojo._notifRateLimit = {}
|
||||
Rojo._changedEvent = Instance.new("BindableEvent")
|
||||
|
||||
Rojo.Changed = Rojo._changedEvent.Event
|
||||
Rojo.Connected = if app.serveSession then app.serveSession:getStatus() == "Connected" else false
|
||||
Rojo.Address = nil
|
||||
Rojo.ProjectName = nil
|
||||
Rojo.Version = table.clone(Config.version)
|
||||
Rojo.ProtocolVersion = Config.protocolVersion
|
||||
|
||||
Rojo._notifRateLimit = {}
|
||||
|
||||
function Rojo:Test(...)
|
||||
print("Rojo:Test called by", Rojo:_getCaller(), "with args", ...)
|
||||
function Rojo:_updateProperty(property: string, value: any?)
|
||||
local oldValue = Rojo[property]
|
||||
Rojo[property] = value
|
||||
Rojo._changedEvent:Fire(property, value, oldValue)
|
||||
end
|
||||
|
||||
function Rojo:_getCallerFull()
|
||||
|
|
@ -85,6 +89,10 @@ function API.new(app)
|
|||
return "CommandBar"
|
||||
end
|
||||
|
||||
function Rojo:Test(...)
|
||||
print("Rojo:Test called by", Rojo:_getCaller(), "with args", ...)
|
||||
end
|
||||
|
||||
function Rojo:ConnectAsync(host: string?, port: number?)
|
||||
app:startSession(host, port)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue