locorda_objects 0.5.0 copy "locorda_objects: ^0.5.0" to clipboard
locorda_objects: ^0.5.0 copied to clipboard

Locorda Objects - Sync offline-first apps using your user's remote storage

locorda_objects #

Type-safe, object-oriented API layer for the locorda CRDT sync engine.

This package wraps the raw SyncEngine (which operates on RdfGraph) with an ObjectSyncEngine that works directly with your Dart domain objects, handling all RDF serialization via RdfMapper transparently.

Most applications should use the locorda package instead. Use locorda_objects directly when building non-Flutter apps or custom abstractions over the sync system.

Features #

  • Type-Safe API: save<Note>(), hydrateStream<Note>(), delete<Note>() — no raw RDF
  • Automatic RDF Mapping: Uses RdfMapper generated by locorda_builder
  • Index Configuration: FullIndexConfig and GroupIndexConfig with RootResourceFetchPolicy
  • Pure Dart: No Flutter dependency — usable in server or CLI contexts

Installation #

dart pub add locorda_objects

Key types #

Type Description
ObjectSyncEngine Main facade — wraps SyncEngine with domain-object API
LocordaConfig Declarative sync configuration for your resource types
ResourceConfig Per-type config: storage layout, index type, fetch policy
FullIndexConfig Single index for all items of a type
GroupIndexConfig Partitioned index with regex-based group keys
RootResourceFetchPolicy onRequest (lazy) or prefetch (eager)
TypedHydrationBatch<T> Decoded batch: updates, deletions, cursor

Usage #

import 'package:locorda_objects/locorda_objects.dart';

final engine = await ObjectSyncEngine.create(
  config: LocordaConfig(
    resources: [
      ResourceConfig<Note>(
        index: FullIndexConfig(fetchPolicy: RootResourceFetchPolicy.prefetch),
        storageLayout: ShardDataset(shardCount: 4),
      ),
    ],
  ),
  mapperInitializer: initRdfMapper, // generated by locorda_builder
  syncEngineFactory: SyncEngine.create,
);

// Stream new/updated/deleted items from remote
engine.hydrateStream<Note>().listen((batch) {
  for (final note in batch.updates) { /* upsert locally */ }
  for (final id in batch.deletions) { /* remove locally */ }
});

// Persist changes — triggers CRDT merge and sync
await engine.save(note);
await engine.delete<Note>('note-id');

Further reading #

0
likes
150
points
0
downloads

Documentation

API reference

Publisher

verified publisherlocorda.dev

Weekly Downloads

Locorda Objects - Sync offline-first apps using your user's remote storage

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#rdf #crdt #solid #offline-first #sync

License

MIT (license)

Dependencies

locorda_core, locorda_rdf_core, locorda_rdf_mapper, logging

More

Packages that depend on locorda_objects