From 2968b70e6b19a0fa096cbe9f810f4d52f15502bc Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Tue, 19 Mar 2019 18:17:03 -0700 Subject: [PATCH] Listen to Plugin.Unloading. Closes #127. --- plugin/src/Components/App.lua | 7 +++++++ plugin/src/init.server.lua | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/src/Components/App.lua b/plugin/src/Components/App.lua index 7d534759..79436972 100644 --- a/plugin/src/Components/App.lua +++ b/plugin/src/Components/App.lua @@ -182,6 +182,13 @@ function App:didMount() preloadAssets() end +function App:willUnmount() + if self.currentSession ~= nil then + self.currentSession:disconnect() + self.currentSession = nil + end +end + function App:didUpdate() local connectActive = self.state.sessionStatus == SessionStatus.ConfiguringSession or self.state.sessionStatus == SessionStatus.Connected diff --git a/plugin/src/init.server.lua b/plugin/src/init.server.lua index dc547c85..b3b52bd0 100644 --- a/plugin/src/init.server.lua +++ b/plugin/src/init.server.lua @@ -4,10 +4,6 @@ end local Roact = require(script.Parent.Roact) -Roact.setGlobalConfig({ - elementTracing = true, -}) - local App = require(script.Components.App) local app = Roact.createElement(App, { @@ -16,4 +12,6 @@ local app = Roact.createElement(App, { Roact.mount(app, game:GetService("CoreGui"), "Rojo UI") --- TODO: Detect another instance of Rojo coming online and shut down this one. \ No newline at end of file +plugin.Unloading:Connect(function() + Roact.unmount(app) +end) \ No newline at end of file