local P=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local Y=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local z=require(P.Packages.Knit)local V=require(P.Game.Modules.State)local I=require(P.Packages.sift)local s=z.CreateController({Name="\068\097\116\097\067\111\110\116\114\111\108\108\101\114"})function s.KnitStart(P) end function s.KnitInit(P)local function s(P,z)if z==nil then z=I.None end V:dispatch({type="\083\101\116\080\108\097\121\101\114\068\097\116\097",key=P,value=z})print(string.format("\071\111\116 \110\101\119 \112\108\097\121\101\114 \100\097\116\097 \037\115\058 \037\115",P,Y:JSONEncode(z)))end local m=z.GetService("\068\097\116\097\083\101\114\118\105\099\101");((m:RequestData()):andThen(function(P)for P,Y in P do s(P,Y)end end)):catch(warn)m.DataChanged:Connect(s)end return s
-- DataController
-- 0_1195
-- May 06, 2022

--[[



]]

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Http = game:GetService("HttpService")

local Knit = require(ReplicatedStorage.Packages.Knit)
local State = require(ReplicatedStorage.Game.Modules.State)
local Sift = require(ReplicatedStorage.Packages.sift)

local Controller = Knit.CreateController({
	Name = "DataController",
})

function Controller:KnitStart() end

function Controller:KnitInit()
	local function dataChanged(key, value)
		if value == nil then
			value = Sift.None
		end

		State:dispatch({
			type = "SetPlayerData",
			key = key,
			value = value,
		})

		print(string.format("Got new player data %s: %s", key, Http:JSONEncode(value)))
	end

	local DataService = Knit.GetService("DataService")
	DataService
		:RequestData()
		:andThen(function(data)
			for k, v in data do
				dataChanged(k, v)
			end
		end)
		:catch(warn)

	DataService.DataChanged:Connect(dataChanged)
end

return Controller
