Files
GRDB.swift/docs/6.3/data/documentation/grdb/sharedvalueobservation.json
2022-11-09 08:57:09 +01:00

1 line
12 KiB
JSON

{"seeAlsoSections":[{"title":"Observing Database Values","identifiers":["doc:\/\/GRDB\/documentation\/GRDB\/AsyncValueObservation","doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation"],"generated":true}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"final"},{"kind":"text","text":" "},{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"SharedValueObservation"},{"kind":"text","text":"<"},{"kind":"genericParameter","text":"Element"},{"kind":"text","text":">"}],"languages":["swift"],"platforms":["macOS"]}]},{"kind":"content","content":[{"anchor":"overview","level":2,"type":"heading","text":"Overview"},{"style":"note","content":[{"type":"paragraph","inlineContent":[{"type":"text","text":""},{"type":"reference","isActive":true,"identifier":"https:\/\/github.com\/groue\/GRDB.swift\/blob\/master\/README.md#what-are-experimental-features"}]}],"type":"aside","name":"Note"},{"type":"paragraph","inlineContent":[{"type":"text","text":"You build a "},{"type":"codeVoice","code":"SharedValueObservation"},{"type":"text","text":" with the "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation"},{"type":"text","text":" method"},{"type":"text","text":" "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation\/shared(in:scheduling:extent:)"},{"type":"text","text":". For example:"}]},{"type":"codeListing","syntax":"swift","code":["let observation = ValueObservation.tracking { db in"," try Player.fetchAll(db)","}","","let sharedObservation = observation.shared(in: dbQueue)","","let cancellable = try sharedObservation.start { error in"," \/\/ handle error","} onChange: { (players: [Player]) in"," print(\"Fresh players: \\(players)\")","}"]},{"type":"paragraph","inlineContent":[{"type":"text","text":"The underlying subscription is shared if and only if you start observing"},{"type":"text","text":" "},{"type":"text","text":"the database from the same "},{"type":"codeVoice","code":"SharedValueObservation"},{"type":"text","text":" instance:"}]},{"type":"codeListing","syntax":"swift","code":["\/\/ Shared","let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)","let cancellable1 = sharedObservation.start(...)","let cancellable2 = sharedObservation.start(...)","","\/\/ NOT shared","let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)","let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)"]}]}],"variants":[{"paths":["\/documentation\/grdb\/sharedvalueobservation"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"A shared value observation spares database resources by sharing a single"},{"type":"text","text":" "},{"type":"text","text":"underlying "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation"},{"type":"text","text":" subscription."}],"kind":"symbol","metadata":{"fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"SharedValueObservation"}],"title":"SharedValueObservation","roleHeading":"Class","role":"symbol","symbolKind":"class","externalID":"s:4GRDB22SharedValueObservationC","modules":[{"name":"GRDB"}],"navigatorTitle":[{"kind":"identifier","text":"SharedValueObservation"}]},"hierarchy":{"paths":[["doc:\/\/GRDB\/documentation\/GRDB","doc:\/\/GRDB\/documentation\/GRDB\/DatabaseObservation"]]},"topicSections":[{"title":"Instance Methods","identifiers":["doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation\/publisher()","doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation\/start(onError:onChange:)","doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation\/values(bufferingPolicy:)"]}],"references":{"doc://GRDB/documentation/GRDB/ValueObservation":{"role":"symbol","title":"ValueObservation","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"ValueObservation"}],"abstract":[{"type":"codeVoice","code":"ValueObservation"},{"type":"text","text":" tracks changes in the results of database requests, and"},{"type":"text","text":" "},{"type":"text","text":"notifies fresh values whenever the database changes."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"ValueObservation"}],"url":"\/documentation\/grdb\/valueobservation"},"doc://GRDB/documentation/GRDB/AsyncValueObservation":{"role":"symbol","title":"AsyncValueObservation","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"AsyncValueObservation"}],"abstract":[{"type":"text","text":"An asynchronous sequence of values observed by a "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation"},{"type":"text","text":"."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/AsyncValueObservation","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"AsyncValueObservation"}],"url":"\/documentation\/grdb\/asyncvalueobservation"},"https://github.com/groue/GRDB.swift/blob/master/README.md#what-are-experimental-features":{"title":"🔥 EXPERIMENTAL","titleInlineContent":[{"type":"strong","inlineContent":[{"type":"text","text":"🔥 EXPERIMENTAL"}]}],"type":"link","identifier":"https:\/\/github.com\/groue\/GRDB.swift\/blob\/master\/README.md#what-are-experimental-features","url":"https:\/\/github.com\/groue\/GRDB.swift\/blob\/master\/README.md#what-are-experimental-features"},"doc://GRDB/documentation/GRDB/SharedValueObservation/publisher()":{"role":"symbol","title":"publisher()","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"publisher"},{"kind":"text","text":"() -> "},{"kind":"typeIdentifier","text":"DatabasePublishers","preciseIdentifier":"s:4GRDB18DatabasePublishersO"},{"kind":"text","text":"."},{"kind":"typeIdentifier","text":"Value","preciseIdentifier":"s:4GRDB18DatabasePublishersO5ValueV"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Element"},{"kind":"text","text":">"}],"abstract":[{"type":"text","text":"Returns a publisher of observed values."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation\/publisher()","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/sharedvalueobservation\/publisher()"},"doc://GRDB/documentation/GRDB/SharedValueObservation/start(onError:onChange:)":{"role":"symbol","title":"start(onError:onChange:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"start"},{"kind":"text","text":"("},{"kind":"externalParam","text":"onError"},{"kind":"text","text":": ("},{"kind":"typeIdentifier","text":"Error","preciseIdentifier":"s:s5ErrorP"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"Void","preciseIdentifier":"s:s4Voida"},{"kind":"text","text":", "},{"kind":"externalParam","text":"onChange"},{"kind":"text","text":": ("},{"kind":"typeIdentifier","text":"Element"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"Void","preciseIdentifier":"s:s4Voida"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"AnyDatabaseCancellable","preciseIdentifier":"s:4GRDB22AnyDatabaseCancellableC"}],"abstract":[{"type":"text","text":"Starts observing the database."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation\/start(onError:onChange:)","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/sharedvalueobservation\/start(onerror:onchange:)"},"doc://GRDB/documentation/GRDB":{"role":"collection","title":"GRDB","abstract":[{"type":"text","text":"A toolkit for SQLite databases, with a focus on application development"}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB","kind":"symbol","type":"topic","url":"\/documentation\/grdb"},"doc://GRDB/documentation/GRDB/SharedValueObservation":{"role":"symbol","title":"SharedValueObservation","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"SharedValueObservation"}],"abstract":[{"type":"text","text":"A shared value observation spares database resources by sharing a single"},{"type":"text","text":" "},{"type":"text","text":"underlying "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation"},{"type":"text","text":" subscription."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"SharedValueObservation"}],"url":"\/documentation\/grdb\/sharedvalueobservation"},"doc://GRDB/documentation/GRDB/SharedValueObservation/values(bufferingPolicy:)":{"role":"symbol","title":"values(bufferingPolicy:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"values"},{"kind":"text","text":"("},{"kind":"externalParam","text":"bufferingPolicy"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"AsyncValueObservation","preciseIdentifier":"s:4GRDB21AsyncValueObservationV"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Element"},{"kind":"text","text":">."},{"kind":"typeIdentifier","text":"BufferingPolicy","preciseIdentifier":"s:4GRDB21AsyncValueObservationV15BufferingPolicya"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"AsyncValueObservation","preciseIdentifier":"s:4GRDB21AsyncValueObservationV"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Element"},{"kind":"text","text":">"}],"abstract":[{"type":"text","text":"Returns an asynchronous sequence of observed values."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SharedValueObservation\/values(bufferingPolicy:)","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/sharedvalueobservation\/values(bufferingpolicy:)"},"doc://GRDB/documentation/GRDB/ValueObservation/shared(in:scheduling:extent:)":{"conformance":{"constraints":[{"type":"codeVoice","code":"Reducer"},{"type":"text","text":" conforms to "},{"type":"codeVoice","code":"_ValueReducer"},{"type":"text","text":"."}],"availabilityPrefix":[{"type":"text","text":"Available when"}],"conformancePrefix":[{"type":"text","text":"Conforms when"}]},"role":"symbol","title":"shared(in:scheduling:extent:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"shared"},{"kind":"text","text":"("},{"kind":"externalParam","text":"in"},{"kind":"text","text":": some "},{"kind":"typeIdentifier","text":"DatabaseReader","preciseIdentifier":"s:4GRDB14DatabaseReaderP"},{"kind":"text","text":", "},{"kind":"externalParam","text":"scheduling"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"ValueObservationScheduler","preciseIdentifier":"s:4GRDB25ValueObservationSchedulerC"},{"kind":"text","text":", "},{"kind":"externalParam","text":"extent"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"SharedValueObservationExtent","preciseIdentifier":"s:4GRDB28SharedValueObservationExtentO"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"SharedValueObservation","preciseIdentifier":"s:4GRDB22SharedValueObservationC"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Reducer"},{"kind":"text","text":"."},{"kind":"typeIdentifier","text":"Value"},{"kind":"text","text":">"}],"abstract":[{"type":"text","text":"Returns a shared value observation that spares database resources by"},{"type":"text","text":" "},{"type":"text","text":"sharing a single underlying "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation"},{"type":"text","text":" subscription."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ValueObservation\/shared(in:scheduling:extent:)","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/valueobservation\/shared(in:scheduling:extent:)"},"doc://GRDB/documentation/GRDB/DatabaseObservation":{"role":"collectionGroup","title":"Database Observation","abstract":[{"type":"text","text":"Observe database changes and transactions."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/DatabaseObservation","kind":"article","type":"topic","url":"\/documentation\/grdb\/databaseobservation"}}}