-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
1,807 additions
and
906 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
/*.rbxm | ||
sourcemap.json | ||
Vunion | ||
build | ||
# Roblox Studio lock files | ||
/*.rbxlx.lock | ||
/*.rbxl.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Changelogs | ||
|
||
Any changes that hold a value should be listed here under the Version that they will be released under. | ||
|
||
## V0.2 | ||
* `Vinum.JustOk` was renamed to `Vinum.AlwaysTrue` for a more descriptive API for begineers | ||
* `Observe:onBind`, which fires the provided function, and then returns a connection disconnector. | ||
* `Vinum.Mirror` object, which is used for directly mirroring Objects' values, as opposed to `Vinum.Match`, which perform a computation instead. | ||
* `Vinum.Reflect` object, which is used directly to mirror a specific object's value. Useful for creating readonly clones of a state object. | ||
* `Vinum.Wrap` object, which is used to derive state objects from a luau-pure signal/RBXScriptSignal. | ||
* A fix for Match, which is to fix an error that can occur when working with self-contained `Vinum.Group` keys. | ||
* `Vinum.Record` object, which is used to store "records" of a specific object's value. | ||
* `Vinum.Version` table, which is used to identify the version that this module is built on | ||
* `Vinum.Destroy` function, which enables you to destroy state objects. | ||
## V0.1 | ||
Initial Release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Vusion: [0.2=0.2]: V0.1 | ||
|
||
Vusion is an ergonomic and efficient binding between Fusion, a UI library, and Vinum, a state management library. | ||
|
||
It is the recommended way to use the two libraries together as it is the "standard" solution, and is guaranteed to be updated as Vinum updates. | ||
|
||
## Special Key | ||
Vusion is packaged with a special fusion key that allows you to either pass a non-table data type or a vinum state object to bind to. | ||
|
||
### Example | ||
```lua | ||
local Vusion = require(path)(Fusion, Vinum) | ||
|
||
local tag = Hold("myTagHere", Vinum.AlwaysTrue) | ||
|
||
Fusion.New "Part" { | ||
[Vusion.Key] = { | ||
Name = Vinum.Calc(function(useState) | ||
return "part" .. useState(tag) | ||
end, Vinum.AlwaysTrue), | ||
Anchored = true | ||
} | ||
} | ||
``` | ||
|
||
## Transformer | ||
|
||
In addition to a special key, Vusion is equiped with a transformer function that allows for communication between fusion objects *(such as Springs and Tweens)*, and Vinum objects. | ||
|
||
### Example | ||
|
||
```lua | ||
local Vusion = require(path)(Fusion, Vinum) | ||
|
||
local Health = Fusion.Value(100) | ||
local vinumHealth = Vusion.toVinum(Health, true) -- the last boolean determines if the return object is writable or not. | ||
|
||
Health:set(40) | ||
print(vinumHealth:get() == Health:get()) -- true | ||
``` | ||
In the previous example, vinumHealth is writable *(therefore is provided with a `set` method)*, however, directly writing to it is discouraged since any changes to `Health` will override `vinumHealth`. | ||
|
||
Additionally, transforming Fusion observers isn't supported as it doesn't make sense to do so. | ||
|
||
## VSpring and VTween | ||
|
||
VSpring and VTween are simply functions that call `toVinum` on a newly created spring/tween object- and the API is identical to the standard Fusion's spring/tween implementation- as such, referring to the Fusion's V0.2 documentation is preferred. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Vusion", | ||
"tree" : { | ||
"$path" : "lib" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
return function(Fusion, Vinum) | ||
local Vusion = {} | ||
|
||
function Vusion.toVinum(fusionObj, writable: boolean) | ||
local holder = Vinum.Hold(fusionObj:get(false), Vinum.RefuseIfSimilar) | ||
Fusion.Observer(fusionObj):onChange(function() | ||
holder:set(fusionObj:get(false)) | ||
end) | ||
|
||
return if writable then holder else Vinum.Reflect(holder) | ||
end | ||
|
||
function Vusion.VSpring(...) | ||
return Vusion.toVinum(Fusion.Spring(...), false) | ||
end | ||
|
||
function Vusion.VTween(...) | ||
return Vusion.toVinum(Fusion.Tween(...), false) | ||
end | ||
|
||
Vusion.Key = { | ||
type = "SpecialKey", | ||
kind = "VusionKey", | ||
stage = "self", | ||
|
||
apply = function(self, values, applyTo, cleanupTasks) | ||
for propName, stateObj in values do | ||
local valueType = type(stateObj) | ||
|
||
if valueType == "table" and stateObj.type == "state" then | ||
local observer = Vinum.Observe(stateObj, Vinum.AlwaysTrue) | ||
observer:onBind(function(newValue) | ||
applyTo[propName] = newValue or "hi" | ||
end) | ||
|
||
table.insert(cleanupTasks, function() | ||
Vinum.Destroy(observer) | ||
end) | ||
elseif valueType ~= "table" then | ||
applyTo[propName] = stateObj | ||
end | ||
end | ||
end | ||
} | ||
|
||
return Vusion | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.