File tree Expand file tree Collapse file tree 7 files changed +47
-3
lines changed
packages/0/src/composables Expand file tree Collapse file tree 7 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -289,7 +289,9 @@ export function createGroup<
289289 }
290290
291291 function onboard ( registrations : Partial < Z > [ ] ) : E [ ] {
292- return registrations . map ( registration => register ( registration ) )
292+ const tickets = selection . batch ( ( ) => registrations . map ( registration => register ( registration ) ) )
293+ if ( toValue ( mandatory ) === 'force' ) selection . mandate ( )
294+ return tickets
293295 }
294296
295297 function reset ( ) {
Original file line number Diff line number Diff line change @@ -587,7 +587,7 @@ export function createNested<
587587 }
588588
589589 function onboard ( registrations : NestedRegistration < Z > [ ] ) : E [ ] {
590- return registrations . map ( registration => register ( registration ) )
590+ return group . batch ( ( ) => registrations . map ( registration => register ( registration ) ) )
591591 }
592592
593593 function clear ( ) : void {
Original file line number Diff line number Diff line change @@ -416,10 +416,15 @@ export function createQueue<
416416
417417 onScopeDispose ( dispose , true )
418418
419+ function onboard ( registrations : Partial < Z > [ ] ) : E [ ] {
420+ return registry . batch ( ( ) => registrations . map ( registration => register ( registration ) ) )
421+ }
422+
419423 return {
420424 ...registry ,
421425 register,
422426 unregister,
427+ onboard,
423428 offboard,
424429 pause,
425430 resume,
Original file line number Diff line number Diff line change @@ -307,7 +307,9 @@ export function createSelection<
307307 }
308308
309309 function onboard ( registrations : Partial < Z > [ ] ) : E [ ] {
310- return registrations . map ( registration => register ( registration ) )
310+ const tickets = registry . batch ( ( ) => registrations . map ( registration => register ( registration ) ) )
311+ if ( toValue ( mandatory ) === 'force' ) mandate ( )
312+ return tickets
311313 }
312314
313315 function reset ( ) {
Original file line number Diff line number Diff line change @@ -185,10 +185,15 @@ export function createFeatures<
185185 }
186186 }
187187
188+ function onboard ( registrations : Partial < Z > [ ] ) : E [ ] {
189+ return registry . batch ( ( ) => registrations . map ( registration => register ( registration ) ) )
190+ }
191+
188192 return {
189193 ...registry ,
190194 variation,
191195 register,
196+ onboard,
192197 sync,
193198 get size ( ) {
194199 return registry . size
Original file line number Diff line number Diff line change @@ -294,11 +294,16 @@ export function createTheme<
294294 return registry . register ( item as unknown as Partial < SingleTicketInput < ThemeColors > > ) as unknown as E
295295 }
296296
297+ function onboard ( registrations : Partial < Z > [ ] ) : E [ ] {
298+ return registry . batch ( ( ) => registrations . map ( registration => register ( registration ) ) )
299+ }
300+
297301 return {
298302 ...registry ,
299303 colors,
300304 isDark,
301305 register,
306+ onboard,
302307 cycle,
303308 get size ( ) {
304309 return registry . size
Original file line number Diff line number Diff line change @@ -140,6 +140,31 @@ const theme = inject('theme') // Could be undefined!
140140const [useTheme, provideTheme] = createContext <ThemeContext >(' Theme' )
141141```
142142
143+ ### ❌ Don't override ` register ` without overriding ` onboard `
144+ ``` ts
145+ // Bad — inherited onboard calls base register via closure, skipping your logic
146+ function register (item ) {
147+ const ticket = registry .register ({ ... defaults , ... item })
148+ doCustomStuff (ticket )
149+ return ticket
150+ }
151+ return { ... registry , register } // onboard still calls base register!
152+ ```
153+
154+ ### ✅ Always pair custom ` register ` with batched ` onboard `
155+ ``` ts
156+ // Good — onboard routes through your register and batches cache/events
157+ function register (item ) {
158+ const ticket = registry .register ({ ... defaults , ... item })
159+ doCustomStuff (ticket )
160+ return ticket
161+ }
162+ function onboard (items ) {
163+ return registry .batch (() => items .map (item => register (item )))
164+ }
165+ return { ... registry , register , onboard }
166+ ```
167+
143168### ❌ Don't write SSR checks manually
144169``` ts
145170// Bad
You can’t perform that action at this time.
0 commit comments