Skip to content

Add tag() action for CollectionService tags#76

Open
BitwiseAndrea wants to merge 1 commit into
centau:mainfrom
BitwiseAndrea:add-tag-action
Open

Add tag() action for CollectionService tags#76
BitwiseAndrea wants to merge 1 commit into
centau:mainfrom
BitwiseAndrea:add-tag-action

Conversation

@BitwiseAndrea

Copy link
Copy Markdown

Summary

Adds a built-in vide.tag() action that wraps Instance:AddTag() / Instance:RemoveTag() so CollectionService tags can be applied directly through create() props, alongside the existing changed() helper.

create "Frame" {
    tag("Clickable"),
    tag({ "Draggable", "Highlightable" }),
    tag(function() return "state-" .. state() end), -- reactive
}
  • Accepts a static string, a { string }, or a reactive source returning either.
  • The reactive variant diffs the previous and new tag sets, so tags present in both are left untouched; only the delta is added/removed.
  • All tags added by the action are removed when the surrounding scope is destroyed (via cleanup).
  • Multiple tag() actions compose on the same instance.
  • Default action priority of 1, matching changed().

Loosely modeled after react-luau's Tag handling, but exposed as an action to fit Vide's existing patterns (rather than a magic prop key). Uses the newer Instance:AddTag / RemoveTag methods directly rather than going through CollectionService.

Changes

  • src/tag.luau — new action implementation.
  • src/lib.luau — exports vide.tag.
  • test/mock.luau — adds AddTag / RemoveTag / HasTag / GetTags to the mock Instance so the action is testable outside Studio.
  • test/tests.luau — 8 new cases covering single/multi/static/reactive tags, scope-destroy cleanup, and composition.
  • docs/api/creation.md — new tag() API reference section.
  • docs/tut/crash-course/12-actions.md — closing note pointing readers at the built-in changed() and tag() helpers.
  • CHANGELOG.md — entry under Unreleased / Added.

Test plan

  • luau test/tests.luau — 130/130 cases pass, including the 8 new tag() cases.
  • Manual smoke test in Studio against a real Instance (Add/Remove/Has/GetTag).

Made with Cursor

Adds a built-in `vide.tag()` action that wraps `Instance:AddTag()` /
`Instance:RemoveTag()` so tags can be applied through `create()` props.

It accepts a static string or array of strings, or a reactive source
returning either. The reactive variant diffs the previous and new tag
sets so only the delta is applied. All tags added by the action are
removed when the surrounding scope is destroyed.

Includes mock support for `AddTag`/`RemoveTag`/`HasTag`/`GetTags`,
tests, API reference docs, and a closing note in the actions tutorial.

Co-authored-by: Cursor <cursoragent@cursor.com>
@isarsindri

Copy link
Copy Markdown

Just repeating what Centau said from another PR
Vide is designed to (mostly) function in vanilla luau, outside of Roblox. Being dependent on (whateverService) makes this another feature that can only be used in Roblox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants