Skip to content

Commit 221bf7f

Browse files
Streamline Unity events documentation based on feedback
- Remove Best Practices section (too general, not AppKit-specific) - Remove Platform Considerations section (irrelevant for events) - Remove SignClient Unity events section (too low-level for client docs) - Keep thread safety info integrated in main introduction - Maintain Event Arguments, subscription patterns, and practical examples - Focus on client-facing AppKit events only Co-Authored-By: gleb@reown.com <gleb@skibitsky.com>
1 parent 413330e commit 221bf7f

File tree

1 file changed

+2
-69
lines changed

1 file changed

+2
-69
lines changed

appkit/unity/core/events.mdx

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
title: Events
33
---
44

5-
AppKit Unity provides a comprehensive event system that allows you to respond to various state changes in your application. All events are automatically dispatched on Unity's main thread, making them safe to use for UI updates.
5+
AppKit Unity provides a comprehensive event system that allows you to respond to various state changes in your application. All events are automatically dispatched on Unity's main thread, making them safe to use for UI updates and GameObject manipulation.
66

77
## AppKit Events
88

9-
### Core Events
10-
119
```csharp
1210
// Invoked after successful initialization of AppKit
1311
AppKit.Initialized += (sender, eventArgs) => {
@@ -48,29 +46,6 @@ AppKit.ChainChanged += (sender, eventArgs) => {
4846
};
4947
```
5048

51-
## SignClient Unity Events
52-
53-
For advanced use cases, you can also subscribe to lower-level SignClient events through `AppKit.Instance.SignClient`:
54-
55-
```csharp
56-
// Subscribe to SignClient Unity events
57-
AppKit.Instance.SignClient.SessionConnectedUnity += (sender, session) => {
58-
Debug.Log($"Session connected: {session.Topic}");
59-
};
60-
61-
AppKit.Instance.SignClient.SessionUpdatedUnity += (sender, session) => {
62-
Debug.Log($"Session updated: {session.Topic}");
63-
};
64-
65-
AppKit.Instance.SignClient.SessionDisconnectedUnity += (sender, eventArgs) => {
66-
Debug.Log("Session disconnected");
67-
};
68-
69-
AppKit.Instance.SignClient.SessionRequestSentUnity += (sender, sessionRequest) => {
70-
Debug.Log($"Session request sent: {sessionRequest.Id}");
71-
};
72-
```
73-
7449
## Event Arguments
7550

7651
### InitializeEventArgs
@@ -92,9 +67,7 @@ Empty event arguments indicating account disconnection.
9267
- `Chain PreviousChain` - The previously active chain (can be null)
9368
- `Chain NewChain` - The newly active chain
9469

95-
## Best Practices
96-
97-
### Event Subscription and Cleanup
70+
## Event Subscription and Cleanup
9871

9972
Always unsubscribe from events to prevent memory leaks:
10073

@@ -137,46 +110,6 @@ public class WalletManager : MonoBehaviour
137110
}
138111
```
139112

140-
### Error Handling
141-
142-
Always wrap event handlers in try-catch blocks to prevent exceptions from breaking the event chain:
143-
144-
```csharp
145-
AppKit.AccountConnected += (sender, eventArgs) => {
146-
try
147-
{
148-
// Your event handling code
149-
UpdateAccountUI(eventArgs.Account);
150-
}
151-
catch (Exception ex)
152-
{
153-
Debug.LogError($"Error handling AccountConnected event: {ex.Message}");
154-
}
155-
};
156-
```
157-
158-
### Thread Safety
159-
160-
All AppKit events are automatically dispatched on Unity's main thread, making them safe for:
161-
- UI updates
162-
- GameObject manipulation
163-
- Component access
164-
165-
No additional thread synchronization is required.
166-
167-
## Platform Considerations
168-
169-
### WebGL vs Native
170-
171-
- **Native platforms** (iOS, Android, Desktop): Full event support with persistent storage
172-
- **WebGL**: All events work the same way, but storage is handled differently using PlayerPrefs
173-
174-
### SignClient Storage
175-
176-
The SignClient automatically handles storage differences between platforms:
177-
- **Native**: Uses file system storage at `Application.persistentDataPath/Reown/storage.json`
178-
- **WebGL**: Uses PlayerPrefs with Unity's synchronization context
179-
180113
## Common Use Cases
181114

182115
### Updating UI on Account Changes

0 commit comments

Comments
 (0)