Skip to content

Commit ffa0210

Browse files
fix(docs): correct JAction state parameter documentation
State overloads DO NOT work with value types - they get boxed when passed as generic parameters. Updated docs to reflect this and recommend closures for value types. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net>
1 parent 3e33da2 commit ffa0210

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

claude-plugin/skills/jaction/SKILL.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,20 @@ await JAction.Create()
7373
.ExecuteAsync();
7474
```
7575

76-
### State Parameter for Zero-Allocation
76+
### State Parameter for Zero-Allocation (Reference Types Only)
7777
```csharp
78-
// CORRECT - no closure allocation (works with both reference and value types)
78+
// CORRECT - no closure allocation with reference types
7979
var data = new MyData();
8080
JAction.Create()
8181
.Do(static (MyData d) => d.Process(), data)
8282
.Execute();
8383

84-
// Also works with value types without boxing
84+
// WARNING: State overloads DO NOT work with value types (int, float, struct, bool, etc.)
85+
// Value types get boxed when passed as generic parameters, defeating zero-allocation
86+
// For value types, use closures instead (allocation is acceptable):
8587
int count = 5;
8688
JAction.Create()
87-
.Do(static (int c) => Debug.Log($"Count: {c}"), count)
89+
.Do(() => Debug.Log($"Count: {count}")) // Closure is fine for value types
8890
.Execute();
8991
```
9092

@@ -109,5 +111,6 @@ action.Cancel();
109111
## Common Mistakes
110112
- NOT using `using var` after ExecuteAsync (memory leak, never returns to pool)
111113
- Using Execute() in production (blocks main thread, causes frame drops)
114+
- Using state overloads with value types (causes boxing - use closures instead)
112115
- Forgetting to call Execute() or ExecuteAsync() (nothing happens)
113116
- Code in .Do() runs atomically and cannot be interrupted - keep callbacks lightweight

0 commit comments

Comments
 (0)