Macro-based CloudKit configuration via @SyncedTable/@SyncedField #352
Replies: 1 comment 1 reply
-
Hi @lukaskubanek, thanks for opening this discussion, and this approach is indeed how Stephen and I think things should go. The key to it is solving what you describe above. To do this we will need to "library-ify" the macros in StructuredQueries. That is, extract out the guts of the macro expansion code into its own library so that its core components can be called from SQ's macros as well as SQLiteData's macros. That will allow That would be the first step towards this, and we plan on looking into it at some point, but also if you are inclined to explore do let us know what you find! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In recent discussions in the SQLiteData repo, a potential pattern has emerged for designing CloudKit-related configuration APIs using macros applied directly to table types and their fields.
The main benefit of this approach is that CloudKit configuration can live close to the data it describes, rather than being defined indirectly in the initializer of
SyncEngine. This also scales better as additional configuration options are added. The main downside is that this likely can’t be folded into the existing@Tablemacro, and would instead require introducing a new sync-aware type-level macro.See these discussions for more context:
I’ve decided to open this high-level discussion specifically to explore the macro-based pattern, and to provide a shared reference point for discussion and experimentation.
Here is a list of options the macro pair could support that come to mind:
@SyncedTabletablesandprivateTablesparameters inSyncEngine.init)@SyncedFieldCKAsset)Example
A definition of a table with minimal configuration options:
The same model with all defaults made explicit and the field-level macros expanded:
This shows how an ideal syntax could look like, but I’m not sure how exactly the
@SyncedTablemacro would get the expansion logic from the stock@Tablemacro, as I’m not that familiar with macro development.I simply wanted to get a sense of whether this is a direction for the library worth exploring, given the new configuration options that are being discussed.
Beta Was this translation helpful? Give feedback.
All reactions