@quenty/brio 3.7.0 → 3.7.2-canary.4c04014.0
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.
- package/CHANGELOG.md +19 -0
- package/package.json +6 -6
- package/src/Shared/RxBrioUtils.lua +16 -38
- package/src/Shared/RxBrioUtils.spec.lua +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.7.2-canary.4c04014.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/brio@3.7.1...@quenty/brio@3.7.2-canary.4c04014.0) (2022-01-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* RxBrioUtils.map correctly maps for n == 1, and RxBrioUtils.where is not a switch map. ([56e3a3a](https://github.com/Quenty/NevermoreEngine/commit/56e3a3a06334a9ca86e02cbec38710b82c61b9f2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [3.7.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/brio@3.7.0...@quenty/brio@3.7.1) (2022-01-16)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @quenty/brio
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [3.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/brio@3.6.0...@quenty/brio@3.7.0) (2022-01-07)
|
|
7
26
|
|
|
8
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/brio",
|
|
3
|
-
"version": "3.7.0",
|
|
3
|
+
"version": "3.7.2-canary.4c04014.0",
|
|
4
4
|
"description": "Brios wrap an object and either are alive or dead",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/loader": "
|
|
30
|
-
"@quenty/maid": "
|
|
31
|
-
"@quenty/rx": "
|
|
32
|
-
"@quenty/statestack": "
|
|
29
|
+
"@quenty/loader": "3.3.1-canary.4c04014.0",
|
|
30
|
+
"@quenty/maid": "2.0.3-canary.4c04014.0",
|
|
31
|
+
"@quenty/rx": "3.7.2-canary.4c04014.0",
|
|
32
|
+
"@quenty/statestack": "3.4.2-canary.4c04014.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "4c040145693283525ba3f4c793cead7abee28fb2"
|
|
38
38
|
}
|
|
@@ -40,7 +40,7 @@ end
|
|
|
40
40
|
@return StateStack<T>
|
|
41
41
|
]=]
|
|
42
42
|
function RxBrioUtils.createStateStack(observable)
|
|
43
|
-
local stateStack = StateStack.new()
|
|
43
|
+
local stateStack = StateStack.new(nil)
|
|
44
44
|
|
|
45
45
|
stateStack._maid:GiveTask(observable:Subscribe(function(value)
|
|
46
46
|
assert(Brio.isBrio(value), "Observable must emit brio")
|
|
@@ -315,30 +315,18 @@ end
|
|
|
315
315
|
]=]
|
|
316
316
|
function RxBrioUtils.where(predicate)
|
|
317
317
|
assert(type(predicate) == "function", "Bad predicate")
|
|
318
|
-
|
|
319
318
|
return function(source)
|
|
320
319
|
return Observable.new(function(sub)
|
|
321
320
|
local maid = Maid.new()
|
|
322
321
|
|
|
323
322
|
maid:GiveTask(source:Subscribe(function(brio)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
return
|
|
329
|
-
end
|
|
323
|
+
assert(Brio.isBrio(brio), "Not a brio")
|
|
324
|
+
if brio:IsDead() then
|
|
325
|
+
return
|
|
326
|
+
end
|
|
330
327
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
maid._lastBrio = newBrio
|
|
334
|
-
sub:Fire(newBrio)
|
|
335
|
-
end
|
|
336
|
-
else
|
|
337
|
-
if predicate(brio) then
|
|
338
|
-
local newBrio = Brio.new(brio)
|
|
339
|
-
maid._lastBrio = newBrio
|
|
340
|
-
sub:Fire(newBrio)
|
|
341
|
-
end
|
|
328
|
+
if predicate(brio:GetValue()) then
|
|
329
|
+
sub:Fire(brio)
|
|
342
330
|
end
|
|
343
331
|
end, sub:GetFailComplete()))
|
|
344
332
|
|
|
@@ -570,27 +558,18 @@ function RxBrioUtils.map(project)
|
|
|
570
558
|
end
|
|
571
559
|
|
|
572
560
|
local results = table.pack(project(table.unpack(args, 1, args.n)))
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
561
|
+
local transformedResults = {}
|
|
562
|
+
for i=1, results.n do
|
|
563
|
+
local item = results[i]
|
|
564
|
+
if Brio.isBrio(item) then
|
|
565
|
+
table.insert(brios, item) -- add all subsequent brios into this table...
|
|
566
|
+
transformedResults[i] = item:GetValue()
|
|
577
567
|
else
|
|
578
|
-
|
|
568
|
+
transformedResults[i] = item
|
|
579
569
|
end
|
|
580
|
-
else
|
|
581
|
-
local transformedResults = {}
|
|
582
|
-
for i=1, results.n do
|
|
583
|
-
local item = results[i]
|
|
584
|
-
if Brio.isBrio(item) then
|
|
585
|
-
table.insert(brios, item) -- add all subsequent brios into this table...
|
|
586
|
-
transformedResults[i] = item:GetValue()
|
|
587
|
-
else
|
|
588
|
-
transformedResults[i] = item
|
|
589
|
-
end
|
|
590
|
-
end
|
|
591
|
-
|
|
592
|
-
return BrioUtils.first(brios, table.unpack(transformedResults, 1, transformedResults.n))
|
|
593
570
|
end
|
|
571
|
+
|
|
572
|
+
return BrioUtils.first(brios, table.unpack(transformedResults, 1, transformedResults.n))
|
|
594
573
|
end)
|
|
595
574
|
end
|
|
596
575
|
|
|
@@ -666,7 +645,6 @@ function RxBrioUtils.toEmitOnDeathObservable(brio, emitOnDeathValue)
|
|
|
666
645
|
sub:Complete()
|
|
667
646
|
else
|
|
668
647
|
sub:Fire(brio:GetValue())
|
|
669
|
-
|
|
670
648
|
return brio:GetDiedSignal():Connect(function()
|
|
671
649
|
sub:Fire(emitOnDeathValue)
|
|
672
650
|
sub:Complete()
|
|
@@ -13,12 +13,14 @@ return function()
|
|
|
13
13
|
it("should execute immediately", function()
|
|
14
14
|
local observe = RxBrioUtils.combineLatest({})
|
|
15
15
|
local brio
|
|
16
|
-
observe:Subscribe(function(result)
|
|
16
|
+
local sub = observe:Subscribe(function(result)
|
|
17
17
|
brio = result
|
|
18
18
|
end)
|
|
19
19
|
expect(brio).to.be.ok()
|
|
20
20
|
expect(Brio.isBrio(brio)).to.equal(true)
|
|
21
21
|
expect(brio:IsDead()).to.equal(true)
|
|
22
|
+
|
|
23
|
+
sub:Destroy()
|
|
22
24
|
end)
|
|
23
25
|
end)
|
|
24
26
|
|
|
@@ -32,7 +34,7 @@ return function()
|
|
|
32
34
|
})
|
|
33
35
|
local brio
|
|
34
36
|
|
|
35
|
-
observe:Subscribe(function(result)
|
|
37
|
+
local sub = observe:Subscribe(function(result)
|
|
36
38
|
brio = result
|
|
37
39
|
end)
|
|
38
40
|
expect(brio).to.be.ok()
|
|
@@ -40,6 +42,8 @@ return function()
|
|
|
40
42
|
expect(not brio:IsDead()).to.equal(true)
|
|
41
43
|
expect(brio:GetValue()).to.be.a("table")
|
|
42
44
|
expect(brio:GetValue().value).to.equal(5)
|
|
45
|
+
|
|
46
|
+
sub:Destroy()
|
|
43
47
|
end)
|
|
44
48
|
end)
|
|
45
49
|
|
|
@@ -60,7 +64,7 @@ return function()
|
|
|
60
64
|
local fireCount = 0
|
|
61
65
|
|
|
62
66
|
it("should execute immediately", function()
|
|
63
|
-
observe:Subscribe(function(result)
|
|
67
|
+
local sub = observe:Subscribe(function(result)
|
|
64
68
|
lastResult = result
|
|
65
69
|
fireCount = fireCount + 1
|
|
66
70
|
end)
|
|
@@ -69,6 +73,8 @@ return function()
|
|
|
69
73
|
expect(Brio.isBrio(lastResult)).to.equal(false)
|
|
70
74
|
expect(lastResult.value).to.equal(5)
|
|
71
75
|
expect(lastResult.otherValue).to.equal(25)
|
|
76
|
+
|
|
77
|
+
sub:Destroy()
|
|
72
78
|
end)
|
|
73
79
|
|
|
74
80
|
it("should reset when the brio is killed", function()
|