Skip to content

Commit

Permalink
V0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sinlerdev committed Dec 20, 2022
1 parent 932a66a commit 1cdd54c
Show file tree
Hide file tree
Showing 61 changed files with 1,807 additions and 906 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/*.rbxm
sourcemap.json
Vunion
build
# Roblox Studio lock files
/*.rbxlx.lock
/*.rbxl.lock
16 changes: 16 additions & 0 deletions CHANGELOG.md
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.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img align = "left" width = 350 src="gh-assets/Banner.svg">
<img align = "left" src="gh-assets/Banner.svg">


<br><br><br><br><br>
Expand All @@ -17,4 +17,4 @@ ___

## Contributing

If you ever want to contribute for the Vinum project, please refer to [this](CONTRIBUTING.MD)
If you ever want to contribute for the Vinum project, please refer to
47 changes: 47 additions & 0 deletions bindings/Vusion/README.md
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.
6 changes: 6 additions & 0 deletions bindings/Vusion/default.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Vusion",
"tree" : {
"$path" : "lib"
}
}
47 changes: 47 additions & 0 deletions bindings/Vusion/lib/init.luau
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
2 changes: 1 addition & 1 deletion code-runners/runner.server.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--!optimize 2
local shouldBenchmark = true
local shouldBenchmark = false
local shouldTest = true

local Tester = require(script.Parent.Tester)
Expand Down
48 changes: 0 additions & 48 deletions docs/API/Calc.md

This file was deleted.

71 changes: 0 additions & 71 deletions docs/API/Group.md

This file was deleted.

48 changes: 0 additions & 48 deletions docs/API/Hold.md

This file was deleted.

49 changes: 0 additions & 49 deletions docs/API/Match.md

This file was deleted.

Loading

0 comments on commit 1cdd54c

Please sign in to comment.