@bazir/utils 0.1.3 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/Network.luau +11 -9
  2. package/package.json +9 -8
package/out/Network.luau CHANGED
@@ -6,9 +6,9 @@ local createError = _Error.createError
6
6
  local _Platform = TS.import(script, TS.getModule(script, "@bazir", "core").out.Platform)
7
7
  local getDebugInfo = _Platform.getDebugInfo
8
8
  local isRunningOnServer = _Platform.isRunningOnServer
9
+ local subscribe = TS.import(script, TS.getModule(script, "@bazir", "state").out.State).subscribe
9
10
  local _State = TS.import(script, TS.getModule(script, "@bazir", "state").out.State)
10
- local value = _State.value
11
- local subscribe = _State.subscribe
11
+ local createState = _State.createState
12
12
  local peek = _State.peek
13
13
  local update = _State.update
14
14
  local write = _State.write
@@ -237,22 +237,24 @@ do
237
237
  end
238
238
  local connectPatches = createEvent(level + 1)
239
239
  local applyPatches = createEvent(level + 1)
240
- local state = value(initialValue)
240
+ local state = createState(initialValue)
241
241
  if isRunningOnServer() then
242
242
  local activePlayers = {}
243
243
  Players.PlayerRemoving:Connect(function(player)
244
244
  local _player = player
245
245
  activePlayers[_player] = nil
246
246
  end)
247
- subscribe(state, function(newValue, prevValue)
248
- local patches = diff(prevValue, newValue)
247
+ subscribe(state, function(newValue, lastValue)
248
+ local patches = diff(lastValue, newValue)
249
249
  if patches == nil then
250
250
  return nil
251
251
  end
252
252
  for player in activePlayers do
253
253
  fireClient(applyPatches, player, patches)
254
254
  end
255
- end)
255
+ end, {
256
+ immediate = true,
257
+ })
256
258
  onServer(connectPatches, function(player)
257
259
  local patches = diff(initialValue, peek(state))
258
260
  if patches ~= nil then
@@ -280,7 +282,7 @@ do
280
282
  end
281
283
  local connectPatches = createEvent(level + 1)
282
284
  local applyPatches = createEvent(level + 1)
283
- local state = value(initialValue)
285
+ local state = createState(initialValue)
284
286
  if isRunningOnServer() then
285
287
  state[SECRET] = {
286
288
  active = {},
@@ -403,8 +405,8 @@ do
403
405
  if isRunningOnServer() then
404
406
  error("useAction can only be called on the client")
405
407
  end
406
- local pending = value(false)
407
- local errorMessage = value(nil)
408
+ local pending = createState(false)
409
+ local errorMessage = createState(nil)
408
410
  local actionCaller = TS.async(function(...)
409
411
  local args = { ... }
410
412
  write(pending, true)
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@bazir/utils",
3
- "version": "0.1.3",
3
+ "version": "0.1.8",
4
4
  "description": "Utility functions for Bazir framework",
5
5
  "main": "out/init.lua",
6
6
  "types": "out/index.d.ts",
7
+ "scripts": {
8
+ "build": "rbxtsc",
9
+ "watch": "rbxtsc -w",
10
+ "prepublishOnly": "pnpm run build"
11
+ },
7
12
  "files": [
8
13
  "out",
9
14
  "!**/*.tsbuildinfo"
@@ -21,18 +26,14 @@
21
26
  "author": "",
22
27
  "license": "ISC",
23
28
  "dependencies": {
24
- "@bazir/core": "^0.1.3",
25
- "@bazir/state": "^0.1.3",
26
- "@bazir/ui": "^0.1.3",
29
+ "@bazir/core": "^0.1.9",
30
+ "@bazir/state": "^0.1.9",
31
+ "@bazir/ui": "^0.1.9",
27
32
  "@rbxts/services": "^1.5.5"
28
33
  },
29
34
  "devDependencies": {
30
35
  "@rbxts/compiler-types": "3.0.0-types.0",
31
36
  "@rbxts/types": "^1.0.841",
32
37
  "typescript": "^5.8.2"
33
- },
34
- "scripts": {
35
- "build": "rbxtsc",
36
- "watch": "rbxtsc -w"
37
38
  }
38
39
  }