You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/WorkoutWorker.md
+6-25Lines changed: 6 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ When a workout is in progress, there are certain responsibilities that sit outsi
4
4
5
5
- Persistent notifications
6
6
- Timers that must continue while the app is backgrounded
7
-
- Integration with platform-specific system UI (e.g. Dynamic Island–style affordances on iOS, foreground notifications on Android)
7
+
- Integration with platform-specific system UI (e.g. foreground notifications on Android)
8
8
9
9
These responsibilities are **inherently platform-dependent**, both in _how_ they are executed and _what_ they integrate with.
10
10
@@ -79,30 +79,24 @@ When the app broadcasts an event:
79
79
80
80
### External representation (cross-platform)
81
81
82
-
For cross-platform communication (JS ↔ native, and parity with iOS), workout messages are serialized using **protobuf**.
83
-
84
-
Protobuf is used strictly as a **wire format**:
85
-
86
-
- Defines the cross-language contract
87
-
- Enables versioning and forwards compatibility
88
-
- Allows binary transport where appropriate
82
+
For cross-platform communication (JS ↔ native, and parity with iOS), workout messages are serialized using **json** via the json schema we generate.
83
+
JSON schemas are generated from our types via (in ./app dir) `npm run json-schema`. This will generate schemas in the docs directory.
89
84
90
85
---
91
86
92
87
### Translation boundary
93
88
94
89
A dedicated translation layer is responsible for converting between:
95
90
96
-
-Protobuf`WorkoutMessage` messages
91
+
-Json Schema`WorkoutMessage` messages
97
92
- Internal domain `WorkoutMessage` objects (events and commands)
98
93
99
94
This translation layer:
100
95
101
96
- Lives on the JS side of the bridge
102
97
- Encapsulates versioning, defaults, and backward compatibility
103
-
- Is the only place where protobuf schema knowledge exists in application code
104
98
105
-
The native bridge receives protobuf bytes directly and uses generated protobuf classes for parsing. The React Native module is responsible only for transport and service lifecycle.
99
+
The native bridge receives a json string directly and uses generated classes for parsing. The React Native module is responsible only for transport and service lifecycle.
106
100
107
101
---
108
102
@@ -111,7 +105,7 @@ The native bridge receives protobuf bytes directly and uses generated protobuf c
111
105
### App → Worker (Events)
112
106
113
107
1. The main app broadcasts a `WorkoutMessage` (event)
114
-
2. The message is serialized using protobuf
108
+
2. The message is serialized using json
115
109
3. The broadcast immediately echoes the event back to all JS listeners
116
110
4. The native bridge forwards the message to the platform worker
117
111
5. The message is dispatched through the worker's in-process message channel
@@ -131,16 +125,3 @@ The native bridge receives protobuf bytes directly and uses generated protobuf c
131
125
-`WorkoutStartedEvent` explicitly starts the worker
132
126
-`WorkoutEndedEvent` explicitly stops the worker
133
127
- Messages outside an active workout lifecycle are ignored
134
-
135
-
---
136
-
137
-
## Non-goals
138
-
139
-
The `WorkoutWorker` explicitly does **not**:
140
-
141
-
- Persist workout state
142
-
- Attempt crash recovery
143
-
- Resume workouts after process death
144
-
- Act as a domain state machine
145
-
146
-
These concerns remain the responsibility of the main application.
0 commit comments