mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 13:21: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)
|
end)
|
||||||
|
|
||||||
serveSession:onStatusChanged(function(status, details)
|
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
|
if not self.headlessAPI.Connected then
|
||||||
self.headlessAPI.Address = nil
|
self.headlessAPI:_updateProperty("Address", nil)
|
||||||
self.headlessAPI.ProjectName = nil
|
self.headlessAPI:_updateProperty("ProjectName", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
if status == ServeSession.Status.Connecting then
|
if status == ServeSession.Status.Connecting then
|
||||||
|
|
@ -284,8 +284,8 @@ function App:startSession(host: string?, port: string?)
|
||||||
elseif status == ServeSession.Status.Connected then
|
elseif status == ServeSession.Status.Connected then
|
||||||
local address = string.format("%s:%s", host :: string, port :: string)
|
local address = string.format("%s:%s", host :: string, port :: string)
|
||||||
|
|
||||||
self.headlessAPI.Address = address
|
self.headlessAPI:_updateProperty("Address", address)
|
||||||
self.headlessAPI.ProjectName = details
|
self.headlessAPI:_updateProperty("ProjectName", details)
|
||||||
|
|
||||||
self:setState({
|
self:setState({
|
||||||
appStatus = AppStatus.Connected,
|
appStatus = AppStatus.Connected,
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,20 @@ local API = {}
|
||||||
function API.new(app)
|
function API.new(app)
|
||||||
local Rojo = {}
|
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.Connected = if app.serveSession then app.serveSession:getStatus() == "Connected" else false
|
||||||
Rojo.Address = nil
|
Rojo.Address = nil
|
||||||
Rojo.ProjectName = nil
|
Rojo.ProjectName = nil
|
||||||
Rojo.Version = table.clone(Config.version)
|
Rojo.Version = table.clone(Config.version)
|
||||||
Rojo.ProtocolVersion = Config.protocolVersion
|
Rojo.ProtocolVersion = Config.protocolVersion
|
||||||
|
|
||||||
Rojo._notifRateLimit = {}
|
function Rojo:_updateProperty(property: string, value: any?)
|
||||||
|
local oldValue = Rojo[property]
|
||||||
function Rojo:Test(...)
|
Rojo[property] = value
|
||||||
print("Rojo:Test called by", Rojo:_getCaller(), "with args", ...)
|
Rojo._changedEvent:Fire(property, value, oldValue)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Rojo:_getCallerFull()
|
function Rojo:_getCallerFull()
|
||||||
|
|
@ -85,6 +89,10 @@ function API.new(app)
|
||||||
return "CommandBar"
|
return "CommandBar"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Rojo:Test(...)
|
||||||
|
print("Rojo:Test called by", Rojo:_getCaller(), "with args", ...)
|
||||||
|
end
|
||||||
|
|
||||||
function Rojo:ConnectAsync(host: string?, port: number?)
|
function Rojo:ConnectAsync(host: string?, port: number?)
|
||||||
app:startSession(host, port)
|
app:startSession(host, port)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue