diff --git a/snippets.json b/snippets.json index 735541509a..ce8fbb931d 100644 --- a/snippets.json +++ b/snippets.json @@ -45,50 +45,50 @@ "array-to-map": "[[collection findByID:docID] updateWithBlock:^(DITMutableDocument *doc) {\n NSMutableDictionary *map = [NSMutableDictionary new];\n NSArray *names = doc[@\"friends\"].arrayValue;\n for (id name in names) {\n NSString *uuid = [[NSUUID UUID] UUIDString];\n map[uuid] = @{\n @\"id\": uuid,\n @\"name\": name\n };\n }\n [doc[@\"friendsMap\"] set:map];\n}];\n\n", "query-sort": "NSArray *sortedRedCars = [[[[ditto.store collection:@\"cars\"]\n find:@\"color == 'red'\"]\n sort:@\"miles\" direction:DITSortDirectionAscending] exec];\n\n", "query-limit": "NSArray *sortedAndLimitedRedCars = [[[[[ditto.store collection:@\"cars\"]\n find:@\"color == 'red'\"]\n sort:@\"miles\" direction:DITSortDirectionAscending]\n limit:100] exec];\n\n", - "sync-basic": "DITDitto *ditto = [TestHelpers makeDitto];\n\nNSError *error = nil;\n[ditto startSync:&error];\n\n", - "write-transaction": "NSArray *results = [store write:^(DITWriteTransaction *tx) {\n DITScopedWriteTransaction *cars = tx[@\"cars\"];\n DITScopedWriteTransaction *people = tx[@\"people\"];\n DITDocumentID *docID = [[DITDocumentID alloc] initWithValue: @\"abc123\"];\n [people upsert:@{@\"_id\": docID, @\"name\": @\"Susan\"} error:nil];\n [cars upsert:@{@\"make\": @\"Ford\", @\"color\": @\"black\", @\"owner\": docID} error:nil];\n [cars upsert:@{@\"make\": @\"Toyota\", @\"color\": @\"red\", @\"owner\": docID} error:nil];\n}];\n\nSuppressUnusedWarning(results);\n\n", - "sync-observe": "DITDitto *ditto = [TestHelpers makeDitto];\n// Register live query to update UI\nDITCollection *collection = [ditto.store collection:@\"cars\"];\nDITLiveQuery *liveQuery = [[collection find:@\"color == 'red'\"]\n observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n\n}];\n\n", - "subscribe": "DITDitto *ditto = [TestHelpers makeDitto];\n// Register live query to update UI\nDITCollection *collection = [ditto.store collection:@\"cars\"];\nDITSubscription *subscription = [[collection find:@\"color == 'red'\"] subscribe];\n\n", - "sync-observe-local": "DITDitto *ditto = [TestHelpers makeDitto];\n// Register live query to update UI\nDITCollection *collection = [ditto.store collection:@\"cars\"];\n\nDITLiveQuery *liveQuery = [[collection find:@\"color == 'red'\"]\n observeLocal:^(NSArray *docs, DITLiveQueryEvent *event) {\n\n}];\n\n", - "shared-key": "// This is just an example. You should use OpenSSL to generate a unique shared key for every application.\n\nNSString *p256_der_b64 = @\"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgFUUrOkOH52QN+Rr6uDSDsk4hUTcD1eW4mT0UnGGptFehRANCAATJ3fG8TVLQcDwUV18BJJI8efK0hQAjzB3VJeYOVbfOlqnfukVId0V25r/abxwjD3HfHuPsCGEiefzzmkMbjPo9\";\nNSURL *dittoPersistenceDir = [TestHelpers randomDittoDir:nil];\nDITIdentity *identity = [[DITIdentity alloc] initSharedKeyWithAppID:@\"app\" sharedKey:p256_der_b64 persistenceDirectory:dittoPersistenceDir];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity];\n\nNSError *error = nil;\nif (![ditto setOfflineOnlyLicenseToken:validLicense error:&error]) {\n NSLog(@\"Error setting license: %@\", error);\n}\n\n", - "online-playground": "// Replace the all-zero app ID with your own app ID\nNSURL *dittoPersistenceDir = [TestHelpers randomDittoDir:nil];\nDITIdentity *identity = [[DITIdentity alloc] initOnlinePlaygroundWithAppID:@\"00000000-0000-4000-0000-000000000000\"\n token:@\"REPLACE_ME_WITH_A_SHARED_TOKEN\"\n enableDittoCloudSync:YES\n persistenceDirectory:dittoPersistenceDir];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity persistenceDirectory: dittoPersistenceDir];\nNSError *error = nil;\n[ditto startSync:&error];\n\n", + "sync-basic": "NSError *error = nil;\n[ditto startSync:&error];\n\n", + "write-transaction": "NSArray *results = [store write:^(DITWriteTransaction *tx) {\n DITScopedWriteTransaction *cars = tx[@\"cars\"];\n DITScopedWriteTransaction *people = tx[@\"people\"];\n DITDocumentID *docID = [[DITDocumentID alloc] initWithValue: @\"abc123\"];\n [people upsert:@{@\"_id\": docID, @\"name\": @\"Susan\"} error:nil];\n [cars upsert:@{@\"make\": @\"Ford\", @\"color\": @\"black\", @\"owner\": docID} error:nil];\n [cars upsert:@{@\"make\": @\"Toyota\", @\"color\": @\"red\", @\"owner\": docID} error:nil];\n}];\n\n", + "sync-observe": "// Register live query to update UI\nDITCollection *collection = [ditto.store collection:@\"cars\"];\nDITLiveQuery *liveQuery = [[collection find:@\"color == 'red'\"]\n observeLocal:^(NSArray *docs, DITLiveQueryEvent *event) {\n\n}];\n\n", + "subscribe": "// Register live query to update UI\nDITCollection *collection = [ditto.store collection:@\"cars\"];\nDITSubscription *subscription = [[collection find:@\"color == 'red'\"] subscribe];\n\n", + "sync-observe-local": "// Register live query to update UI\nDITCollection *collection = [ditto.store collection:@\"cars\"];\n\nDITLiveQuery *liveQuery = [[collection find:@\"color == 'red'\"]\n observeLocal:^(NSArray *docs, DITLiveQueryEvent *event) {\n\n}];\n\n", + "shared-key": "// This is just an example. You should use OpenSSL to generate a unique shared key for every application.\nNSString *p256_der_b64 = @\"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgFUUrOkOH52QN+Rr6uDSDsk4hUTcD1eW4mT0UnGGptFehRANCAATJ3fG8TVLQcDwUV18BJJI8efK0hQAjzB3VJeYOVbfOlqnfukVId0V25r/abxwjD3HfHuPsCGEiefzzmkMbjPo9\";\n\nDITIdentity *identity = [[DITIdentity alloc] initSharedKeyWithAppID:@\"app\" sharedKey:p256_der_b64 persistenceDirectory:dittoPersistenceDir];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity];\n\nNSError *error = nil;\nif (![ditto setOfflineOnlyLicenseToken:validLicense error:&error]) {\n NSLog(@\"Error setting license: %@\", error);\n}\n\n", + "online-playground": "// Replace the all-zero app ID with your own app ID\nDITIdentity *identity = [[DITIdentity alloc] initOnlinePlaygroundWithAppID:@\"00000000-0000-4000-0000-000000000000\"\n token:@\"REPLACE_ME_WITH_A_SHARED_TOKEN\"\n enableDittoCloudSync:YES\n persistenceDirectory:dittoPersistenceDir];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity persistenceDirectory: dittoPersistenceDir];\nNSError *error = nil;\n[ditto startSync:&error];\n\n", "offline-playground": "// Replace the all-zero app ID with your own app ID\nDITIdentity *identity = [[DITIdentity alloc] initOfflinePlaygroundWithAppID:@\"00000000-0000-4000-0000-000000000000\"];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity];\nNSError *error = nil;\nif (![ditto setOfflineOnlyLicenseToken:validLicense error:&error]) {\n NSLog(@\"Error setting license: %@\", error);\n}\nif (![ditto startSync:&error]) {\n NSLog(@\"Error starting sync: %@\", error);\n}\n[ditto startSync:&error];\n\n", "network-remote-ditto": "DITMutableTransportConfig *transportConfig = [[DITMutableTransportConfig alloc] init];\n[transportConfig.connect.tcpServers addObject:@\"135.1.5.5:12345\"];\n[transportConfig.connect.tcpServers addObject:@\"185.1.5.5:12345\"];\n[ditto setTransportConfig:transportConfig];\nNSError *err = nil;\n[ditto startSync:&err];\n\n", "network-listen": "DITMutableTransportConfig *transportConfig = [[DITMutableTransportConfig alloc] init];\n[transportConfig.listen.tcp setEnabled:true];\n[transportConfig.listen.tcp setInterfaceIp:@\"0.0.0.0\"];\n[transportConfig.listen.tcp setPort:4000];\n[ditto setTransportConfig:transportConfig];\nNSError *err = nil;\n[ditto startSync:&err];\n\n", "network-multiple-transports": "DITMutableTransportConfig *transportConfig = [[DITMutableTransportConfig alloc] init];\n// 1. Enable Local Area Network Connections\n[transportConfig enableAllPeerToPeer];\n// 2. Listen for incoming connections on port 4000\n[transportConfig.listen.tcp setEnabled:true];\n[transportConfig.listen.tcp setInterfaceIp:@\"0.0.0.0\"];\n[transportConfig.listen.tcp setPort:4000];\n// 3. Connect explicitly to remote devices\n[transportConfig.connect.tcpServers addObject:@\"135.1.5.5:12345\"];\n[transportConfig.connect.tcpServers addObject:@\"185.1.5.5:12345\"];\n\n[ditto setTransportConfig:transportConfig];\nNSError *err = nil;\n[ditto startSync:&err];\n\n", "network-monitor-conditions": "// Setting up inside a ViewController\nDITIdentity *identity = [[DITIdentity alloc] initOnlinePlaygroundWithAppID:@\"REPLACE_WITH_APP_ID\" token:@\"REPLACE_WITH_PLAYGROUND_TOKEN\"];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity];\nditto.delegate = self;\n[ditto startSync:nil];\n \n// Now you can observe real time changes to the transport conditions:\n@interface ViewController () \n\n@end\n\n@implementation ViewController\n\n- (void)transportConditionChanged:(enum DITTransportCondition)condition forSubsystem:(enum DITConditionSource)source {\n if (condition == DITTransportConditionBleDisabled) {\n NSLog(@\"BLE disabled\");\n } else if (condition == DITTransportConditionNoBleCentralPermission) {\n NSLog(@\"Permission missing for BLE\");\n } else if (condition == DITTransportConditionNoBlePeripheralPermission) {\n NSLog(@\"Permission missing for BLE\");\n }\n}\n\n@end\n\n", - "network-query-overlap-group": "NSString *const orders = @\"orders\";\n\n// The passenger only observes orders that they created\n[[[passenger.store collection:orders] find:@\"user_id==abc123\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render my orders in a list UI\n}];\n\n// Crew member devices observe all orders that everyone created\n[[[crewA.store collection:orders] find:@\"status == 'OPEN'\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders in a list UI\n}];\n\n[[[crewB.store collection:orders] find:@\"status == 'OPEN'\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders\n}];\n\n// Set up our query overlap group and priorities such that the crew members\n// will construct multihop connections with each other.\n[DITExperimental setQueryOverlapGroup:2 ditto:crewA];\n[DITExperimental setQueryOverlapGroup:2 ditto:crewB];\n\n// Query overlap groups should be set before startSync\n[crewA startSync:nil];\n[crewB startSync:nil];\n[passenger startSync:nil];\n\n", + "network-query-overlap-group": "NSString *const orders = @\"orders\";\n\n// The passenger only observes orders that they created\n[[[passenger.store collection:orders] find:@\"user_id==abc123\"] observeLocal:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render my orders in a list UI\n}];\n\n// Crew member devices observe all orders that everyone created\n[[[crewA.store collection:orders] find:@\"status == 'OPEN'\"] observeLocal:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders in a list UI\n}];\n\n[[[crewB.store collection:orders] find:@\"status == 'OPEN'\"] observeLocal:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders\n}];\n\n// Set up our query overlap group and priorities such that the crew members\n// will construct multihop connections with each other.\n[DITExperimental setQueryOverlapGroup:2 ditto:crewA];\n[DITExperimental setQueryOverlapGroup:2 ditto:crewB];\n\n// Query overlap groups should be set before startSync\n[crewA startSync:nil];\n[crewB startSync:nil];\n[passenger startSync:nil];\n\n", "network-set-priority": "[DITExperimental setPriority:DITConnectionPriorityHigh\n forQueryOverlapGroup:2 ditto:crewA];\n[DITExperimental setPriority:DITConnectionPriorityHigh\n forQueryOverlapGroup:2 ditto:crewB];\n\n", "evict": "NSArray *evictedIDs = [[collection find:@\"make == 'Honda'\"] evict];\n\n" }, "swift": { - "shared-key": "// This is just an example. You should use OpenSSL to generate a unique shared key for every application.\nlet p256DerB64 = \"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgFUUrOkOH52QN+Rr6uDSDsk4hUTcD1eW4mT0UnGGptFehRANCAATJ3fG8TVLQcDwUV18BJJI8efK0hQAjzB3VJeYOVbfOlqnfukVId0V25r/abxwjD3HfHuPsCGEiefzzmkMbjPo9\"\n\nlet identity = DittoIdentity.sharedKey(appID: \"app\", sharedKey: p256DerB64, persistenceDirectory: dittoPersistenceDir)\nlet ditto = Ditto(identity: identity, persistenceDirectory: dittoPersistenceDir)\ntry! ditto.setOfflineOnlyLicenseToken(validLicense);\n\n", - "write-transaction": "ditto.store.write { transaction in\n let cars = transaction.scoped(toCollectionNamed: \"cars\")\n let people = transaction.scoped(toCollectionNamed: \"people\")\n let docId = \"abc123\"\n try! people.upsert([\"_id\": docId, \"name\": \"Susan\"])\n try! cars.upsert([\"make\": \"Ford\", \"color\": \"red\", \"owner\": docId])\n try! cars.upsert([\"make\": \"Toyota\", \"color\": \"black\", \"owner\": docId])\n people.findByID(docId).evict()\n}\n\n", - "online-playground": "let ditto = Ditto(identity: DittoIdentity.onlinePlayground(\n // Replace the all-zero app ID with your own app ID\n appID: \"00000000-0000-4000-0000-000000000000\",\n token: \"REPLACE_ME_WITH_A_SHARED_TOKEN\"\n))\ntry! ditto.startSync()\n\n", + "shared-key": "// This is just an example. You should use OpenSSL to generate a unique shared key for every application.\nlet p256DerB64 = \"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgFUUrOkOH52QN+Rr6uDSDsk4hUTcD1eW4mT0UnGGptFehRANCAATJ3fG8TVLQcDwUV18BJJI8efK0hQAjzB3VJeYOVbfOlqnfukVId0V25r/abxwjD3HfHuPsCGEiefzzmkMbjPo9\"\n\nlet identity = DittoIdentity.sharedKey(appID: \"app\", sharedKey: p256DerB64, persistenceDirectory: dittoPersistenceDir)\nlet ditto = Ditto(identity: identity, persistenceDirectory: dittoPersistenceDir)\ndo {\n try ditto.setOfflineOnlyLicenseToken(validLicense);\n} catch (let err) {\n print(err.localizedDescription)\n}\n\n", + "write-transaction": "ditto.store.write { transaction in\n let cars = transaction.scoped(toCollectionNamed: \"cars\")\n let people = transaction.scoped(toCollectionNamed: \"people\")\n let docId = \"abc123\"\n do {\n try people.upsert([\"_id\": docId, \"name\": \"Susan\"])\n try cars.upsert([\"make\": \"Ford\", \"color\": \"red\", \"owner\": docId])\n try cars.upsert([\"make\": \"Toyota\", \"color\": \"black\", \"owner\": docId])\n } catch (let err) {\n print(err.localizedDescription)\n }\n people.findByID(docId).evict()\n}\n\n", + "online-playground": "let ditto = Ditto(identity: DittoIdentity.onlinePlayground(\n // Replace the all-zero app ID with your own app ID\n appID: \"00000000-0000-4000-0000-000000000000\",\n token: \"REPLACE_ME_WITH_A_SHARED_TOKEN\"\n))\ndo {\n try ditto.startSync()\n} catch (let err) {\n print(err.localizedDescription)\n}\n\n", "offline-playground": "var ditto = Ditto(identity: DittoIdentity.offlinePlayground(\n // Replace the all-zero app ID with your own app ID\n appID: \"00000000-0000-4000-0000-000000000000\"\n))\ntry! ditto.setOfflineOnlyLicenseToken(validLicense);\ntry! ditto.startSync()\n\n", "datamodel": "let carsCollection = ditto.store[\"cars\"]\n// or\nlet carsCollection = ditto.store.collection(\"cars\")\n\n", - "attachment": "let collection = ditto.store[\"foo\"]\n\nlet myImageURL = bundle.url(forResource: \"image\", withExtension: \"png\")!\n\nlet metadata = [\"name\": \"my_image.png\"]\nlet attachment = collection.newAttachment(\n path: myImageURL.path,\n metadata: metadata\n)!\n\nlet docID = try! collection.upsert([\"some\": \"string\", \"my_attachment\": attachment])\n\n// Later, find the document and the fetch the attachment\n\nlet doc = collection.findByID(docID).exec()\nlet attachmentToken = doc![\"my_attachment\"].attachmentToken!\n\nlet fetcher = collection.fetchAttachment(token: attachmentToken) { status in\n switch status {\n case .completed(let fetchedAttachment):\n // Do something with attachment\n break\n default:\n print(\"Unable to fetch attachment\")\n break\n }\n}\n\n", - "upsert-default-data": "let docID = try! ditto.store[\"people\"].upsert([\n \"name\": \"Susan\",\n \"age\": 31\n], writeStrategy: .insertDefaultIfAbsent)\n\n", - "upsert-composite-primary-key": "let docID = try! ditto.store[\"people\"].upsert([\n \"_id\": [ \"userId\": \"456abc\", \"workId\": 789 ],\n \"name\": \"Susan\",\n \"age\": 31\n])\nprint(docID) // \"[ \"userId\": \"456abc\", \"workId\": 789 ]\"\n\n", - "upsert-datatypes": "// Insert JSON-compatible data into Ditto\ntry! ditto.store[\"foo\"].upsert([\n \"boolean\": true,\n \"string\": \"Hello World\",\n \"number\": 10,\n \"map\": [\"key\": \"value\"],\n \"array\": [1,2,3],\n \"null\": nil\n])\n\n", - "counter": "let docId = try! ditto.store[\"people\"].upsert([\n \"name\": \"Frank\",\n \"ownedCars\": 0 // here 0 is a number\n])\n\nditto.store[\"people\"].findByID(docId).update({ mutableDoc in\n mutableDoc?[\"ownedCars\"].set(DittoCounter())\n mutableDoc?[\"ownedCars\"].counter?.increment(by: 1)\n})\n\n", - "update": "let docID = try! ditto.store[\"people\"].upsert([\n \"name\": \"Frank\",\n \"age\": 31,\n \"ownedCars\": 0\n])\n\nditto.store[\"people\"].findByID(docID).update { mutableDoc in\n mutableDoc?[\"age\"] = 32\n mutableDoc?[\"ownedCars\"].set(DittoCounter())\n mutableDoc?[\"ownedCars\"].counter?.increment(by: 1)\n}\n\n", - "array-to-map": "collection.findByID(docID).update { doc in\n if (doc == nil) {\n print(\"Document with id=\\(docID) not found\")\n return\n }\n \n var names = doc?[\"friends\"].arrayValue\n var dict = Dictionary()\n \n names.map { name in\n var friend: NSMutableDictionary = [:]\n let id = UUID().uuidString\n friend[\"id\"] = id\n friend[\"name\"] = name\n dict.updateValue(friend, forKey: id)\n }\n doc?[\"friendsMap\"].set(dict)\n}\n\n", - "upsert": "// upsert JSON-compatible data into Ditto\nlet docID = try! ditto.store[\"people\"].upsert([\n \"name\": \"Susan\",\n \"age\": 31\n])\n\n", - "upsert-id": "// upsert JSON-compatible data into Ditto\nlet docID = try! ditto.store[\"people\"].upsert([\n \"_id\": \"abc123\",\n \"name\": \"Susan\",\n \"age\": 31\n])\n\n", + "attachment": "let collection = ditto.store[\"foo\"]\n\nlet myImageURL = bundle.url(forResource: \"image\", withExtension: \"png\")!\n\nlet metadata = [\"name\": \"my_image.png\"]\nlet attachment = collection.newAttachment(\n path: myImageURL.path,\n metadata: metadata\n)!\n\nguard let docID = try? collection.upsert([\"some\": \"string\", \"my_attachment\": attachment]) else{\n //hanlde error\n return\n}\n\n// Later, find the document and the fetch the attachment\n\nlet doc = collection.findByID(docID).exec()\nlet attachmentToken = doc![\"my_attachment\"].attachmentToken!\n\nlet fetcher = collection.fetchAttachment(token: attachmentToken) { status in\n switch status {\n case .completed(let fetchedAttachment):\n // Do something with attachment\n break\n default:\n print(\"Unable to fetch attachment\")\n break\n }\n}\n\n", + "upsert-default-data": "do {\n let docID = try ditto.store[\"people\"].upsert([\n \"name\": \"Susan\",\n \"age\": 31\n ], writeStrategy: .insertDefaultIfAbsent)\n} catch {\n //handle error\n print(error)\n}\n\n", + "upsert-composite-primary-key": "do {\n let docID = try ditto.store[\"people\"].upsert([\n \"_id\": [ \"userId\": \"456abc\", \"workId\": 789 ],\n \"name\": \"Susan\",\n \"age\": 31\n ])\n print(docID) // \"[ \"userId\": \"456abc\", \"workId\": 789 ]\"\n} catch {\n //handle error\n print(error)\n}\n\n", + "upsert-datatypes": "do {\n // Insert JSON-compatible data into Ditto\n try ditto.store[\"foo\"].upsert([\n \"boolean\": true,\n \"string\": \"Hello World\",\n \"number\": 10,\n \"map\": [\"key\": \"value\"],\n \"array\": [1,2,3],\n \"null\": nil\n ])\n}\ncatch {\n //handle error\n print(error)\n}\n\n", + "counter": "do {\n let docId = try ditto.store[\"people\"].upsert([\n \"name\": \"Frank\",\n \"ownedCars\": 0 // here 0 is a number\n ])\n \n ditto.store[\"people\"].findByID(docId).update({ mutableDoc in\n mutableDoc?[\"ownedCars\"].set(DittoCounter())\n mutableDoc?[\"ownedCars\"].counter?.increment(by: 1)\n })\n} catch {\n //handle error\n print(error)\n}\n\n", + "update": "do {\n let docID = try ditto.store[\"people\"].upsert([\n \"name\": \"Frank\",\n \"age\": 31,\n \"ownedCars\": 0\n ])\n\n ditto.store[\"people\"].findByID(docID).update { mutableDoc in\n mutableDoc?[\"age\"] = 32\n mutableDoc?[\"ownedCars\"].set(DittoCounter())\n mutableDoc?[\"ownedCars\"].counter?.increment(by: 1)\n }\n} catch {\n //handle error\n print(error)\n}\n\n", + "array-to-map": "collection.findByID(docID).update { doc in\n guard let doc = doc else {\n print(\"Document with id=\\(docID) not found\")\n return\n }\n \n var names = doc[\"friends\"].arrayValue\n var dict = Dictionary()\n \n names.map { name in\n var friend: NSMutableDictionary = [:]\n let id = UUID().uuidString\n friend[\"id\"] = id\n friend[\"name\"] = name\n dict.updateValue(friend, forKey: id)\n }\n doc[\"friendsMap\"].set(dict)\n}\n\n", + "upsert": "do {\n // upsert JSON-compatible data into Ditto\n let docID = try ditto.store[\"people\"].upsert([\n \"name\": \"Susan\",\n \"age\": 31\n ])\n XCTAssertNotNil(docID)\n} catch {\n //handle error\n print(error)\n}\n\n", + "upsert-id": "do {\n // upsert JSON-compatible data into Ditto\n let docID = try ditto.store[\"people\"].upsert([\n \"_id\": \"abc123\",\n \"name\": \"Susan\",\n \"age\": 31\n ])\n XCTAssertEqual(docID, \"abc123\")\n} catch {\n //handle error\n print(error)\n}\n\n", "query-basic": "let collection = ditto.store[\"people\"]\n .find(\"favoriteBook.title == 'The Great Gatsby'\")\n .exec()\n\n", "query-args": "let documents = ditto.store[\"users\"].find(\"name == $args.name && age <= $args.age\", args: [\n \"age\": 32,\n \"name\": \"Max\"\n]).exec()\n\n", "query-sort": "let sortedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", direction: .ascending)\n .exec()\n\n", "query-limit": "let sortedAndLimitedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", direction: .ascending)\n .limit(100)\n .exec()\n\n", - "sync-observe-local": "// --- Action somewhere in your application\nfunc userDidInsertCar() {\n _ = try! ditto.store.collection(\"cars\").upsert([\n \"model\": \"Ford\",\n \"color\": \"black\"\n ])\n}\n\n// Register live query to update UI\nlet liveQuery = ditto.store.collection(\"cars\").find(\"color == 'red'\")\n .observeLocal { cars, event in\n // do something\n }\n\n", - "sync-observe": "// Register live query to update UI\nlet example = ditto.store.collection(\"cars\").find(\"color == 'red'\")\n .observe { cars, event in\n // do something\n}\n\n", + "sync-observe-local": "// --- Action somewhere in your application\nfunc userDidInsertCar() {\n _ = try? ditto.store.collection(\"cars\").upsert([\n \"model\": \"Ford\",\n \"color\": \"black\"\n ])\n}\n\n// Register live query to update UI\nlet liveQuery = ditto.store.collection(\"cars\").find(\"color == 'red'\")\n .observeLocal { cars, event in\n // do something\n }\n\n", + "sync-observe": "// Register live query to update UI\nlet example = ditto.store.collection(\"cars\").find(\"color == 'red'\")\n .observeLocal { cars, event in\n // do something\n}\n\n", "subscribe": "// Register live query to update UI\nlet subscription = ditto.store.collection(\"cars\").find(\"color == 'red'\").subscribe()\n\n", "network-remote-ditto": "let config = DittoTransportConfig()\n// Connect explicitly to a remote devices\nconfig.connect.tcpServers.add(\"135.1.5.5:12345\")\nconfig.connect.tcpServers.add(\"185.1.5.5:12345\")\n\nditto.transportConfig = config\n\ndo {\n try ditto.startSync()\n} catch (let err) {\n print(err.localizedDescription)\n}\n\n", "device-name": "ditto.deviceName = \"Susan B.\"\nlet observer = ditto.observePeersV2 { json in\n let peers = DittoPeerV2Parser.parseJson(json: json)!\n if !peers.isEmpty {\n // render peers\n }\n}\n\ndo {\n try ditto.startSync()\n} catch (let err) {\n print(err.localizedDescription)\n}\n\n", "network-listen": "let config = DittoTransportConfig()\n\n// Listen for incoming connections on port 4000\nconfig.listen.tcp.isEnabled = true\nconfig.listen.tcp.interfaceIp = \"0.0.0.0\"\nconfig.listen.tcp.port = 4000\n\nditto.transportConfig = config\n\ndo {\n try ditto.startSync()\n} catch (let err) {\n print(err.localizedDescription)\n}\n\n", "network-multiple-transports": "var config = DittoTransportConfig()\n// 1. Enable All Peer to Peer Connections\nconfig.enableAllPeerToPeer()\n\n// 2. Listen for incoming connections on port 4000\nconfig.listen.tcp.isEnabled = true\nconfig.listen.tcp.interfaceIp = \"0.0.0.0\"\nconfig.listen.tcp.port = 4000\n\n// 3. Connect explicitly to remote devices\nconfig.connect.tcpServers.add(\"135.1.5.5:12345\")\nconfig.connect.tcpServers.add(\"185.1.5.5:12345\")\n\nditto.transportConfig = config\n\ndo {\n try ditto.startSync()\n} catch (let err) {\n print(err.localizedDescription)\n}\n\n", "network-monitor-conditions": "// Setting up inside a ViewController\nlet ditto = Ditto(identity: DittoIdentity.onlinePlayground(appID: \"00000000-0000-4000-0000-000000000000\", token: \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\"))\nditto.delegate = self\ntry! ditto.startSync()\n\n// Now you can observe real time changes to the transport conditions:\nextension ViewController: DittoDelegate {\n func transportConditionDidChange(transportID: Int64, condition: TransportCondition) {\n if condition == .BleDisabled {\n print(\"BLE disabled\")\n } else if condition == .NoBleCentralPermission {\n print(\"Permission missing for BLE\")\n } else if condition == .NoBlePeripheralPermission {\n print(\"Permission missing for BLE\")\n }\n }\n\n\n", - "network-query-overlap-group": "// The passenger only observes orders that they created\npassenger.store.collection(\"orders\").find(\"user_id==abc123\").observe { docs, event in\n // render passenger orders in a list UI\n}\n\n// Crew member devices observe all orders that everyone created\ncrewA.store.collection(\"orders\").findAll().observe { docs, event in\n // render all orders in a list UI\n}\ncrewB.store.collection(\"orders\").findAll().observe { docs, event in\n // render all orders in a list UI\n}\n\n// Set up our query overlap group and priorities such that the crew members\n// will construct multihop connections with each other.\nDittoExperimental.setQueryOverlapGroup(queryOverlapGroup: 2, ditto: crewA)\nDittoExperimental.setQueryOverlapGroup(queryOverlapGroup: 2, ditto: crewB)\n\n// Query overlap groups should be set before startSync\ntry! crewA.startSync()\ntry! crewB.startSync()\ntry! passenger.startSync()\n\n", + "network-query-overlap-group": "// The passenger only observes orders that they created\nlet passengerQuery = passenger.store.collection(\"orders\").find(\"user_id==abc123\")\nlet passengerSubscription = passengerQuery.subscribe()\nlet passengerLiveQuery = passengerQuery.observeLocal { docs, event in\n // render passenger orders in a list UI\n}\n\n// Crew member devices observe all orders that everyone created\nlet crewAQuery = crewA.store.collection(\"orders\").findAll()\nlet crewASubscription = crewAQuery.subscribe()\nlet crewALiveQuery = crewAQuery.observeLocal { docs, event in\n // render all orders in a list UI\n}\nlet crewBQuery = crewB.store.collection(\"orders\").findAll()\nlet crewBSubscription = crewBQuery.subscribe()\nlet crewBLiveQuery = crewBQuery.observeLocal { docs, event in\n // render all orders in a list UI\n}\n\n// Set up our query overlap group and priorities such that the crew members\n// will construct multihop connections with each other.\nDittoExperimental.setQueryOverlapGroup(queryOverlapGroup: 2, ditto: crewA)\nDittoExperimental.setQueryOverlapGroup(queryOverlapGroup: 2, ditto: crewB)\n\n// Query overlap groups should be set before startSync\ntry! passenger.startSync()\ntry! crewA.startSync()\ntry! crewB.startSync()\n\n", "network-set-priority": "DittoExperimental.setPriority(DittoConnectionPriority.high, forQueryOverlapGroup: 2, ditto: crewA)\nDittoExperimental.setPriority(DittoConnectionPriority.high, forQueryOverlapGroup: 2, ditto: crewB)\n\n", "evict": "collection.find(\"owner == 'Bob'\").evict()\n\n", "remove-query": "collection.find(\"owner == 'Bob'\").remove()\n\n", @@ -147,7 +147,7 @@ "upsert-default-data": "const docID = await ditto.store.collection('people').upsert(\n {\n name: 'Susan',\n age: 31,\n },\n { writeStrategy: 'insertDefaultIfAbsent' },\n)\n\n", "upsert-composite-primary-key": "const docID = await ditto.store.collection('people').upsert({\n _id: { userID: '456abc', workID: 789 },\n name: 'Susan',\n age: 31,\n})\nconsole.log(docID) // \"{ \"userID\": \"456abc\", \"workID\": 789 }\"\n\n", "update": "const docID = await ditto.store.collection('people').upsert({\n name: 'Frank',\n age: 31,\n ownedCars: 0,\n})\n\nawait ditto.store\n .collection('people')\n .findByID(docID)\n .update((mutableDoc) => {\n mutableDoc.at('age').set(32)\n\n mutableDoc.at('ownedCars').set(new Counter())\n mutableDoc.at('ownedCars').counter.increment(1)\n })\n\n", - "array-to-map": "await collection.findByID(docID).update((mutableDoc) => {\n const map = {}\n const array = mutableDoc.at('friends').array\n array.forEach((name) => {\n const id = getUUID()\n map[id] = { id, name }\n })\n mutableDoc.at('friendsMap').set(map)\n})\n\n", + "array-to-map": "await collection.findByID(docID).update((mutableDoc) => {\n const map = {}\n const array = mutableDoc.at('friends').value\n array.forEach((name) => {\n const id = getUUID()\n map[id] = { id, name }\n })\n mutableDoc.at('friendsMap').set(map)\n})\n\n", "query-basic": "const collection = await ditto.store.collection('people').find(\"favoriteBook.title == 'The Great Gatsby'\")\n\n", "remove-id": "await ditto.store.collection('people').findByID(docID).remove()\n\n", "query-args": "const query = 'name == $args.name && age <= $args.age'\nconst documents = await ditto.store.collection('people').find(query, {\n age: 32,\n name: 'Max',\n})\n\n", @@ -156,7 +156,7 @@ "query-limit": "const sortedAndLimitedRedCars = await ditto.store.collection('cars').find(\"color == 'red'\").sort('miles', 'ascending').limit(100)\n\n", "evict": "await ditto.store.collection('people').find('age <= 32').evict()\n\n", "sync-basic": "try {\n ditto.startSync()\n} catch (err) {\n console.error(err)\n}\n\n", - "sync-observe": "const liveQuery = ditto.store\n .collection('cars')\n .find(\"color == 'red'\")\n .observe((cars, event) => {\n // do something\n })\n\n", + "sync-observe": "const liveQuery = ditto.store\n .collection('cars')\n .find(\"color == 'red'\")\n .observeLocal((cars, event) => {\n // do something\n })\n\n", "subscribe": "const subscription = ditto.store.collection('cars').find(\"color == 'red'\").subscribe()\n\n", "sync-observe-local": "const liveQuery = ditto.store\n .collection('cars')\n .find(\"color == 'red'\")\n .observeLocal((cars, event) => {\n // do something\n })\n\n", "attachment": "const collection = ditto.store.collection('foo')\n\nconst myImageBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEW10NBjBBbqAAAAH0lEQVRoge3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAvg0hAAABmmDh1QAAAABJRU5ErkJggg=='\nconst myImageBytes = Uint8Array.from(myImageBase64, (character) => character.charCodeAt(0))\nconst metadata = { name: 'image.png' }\n\n// On Node, you can also pass a file path (string) instead of image data\n// and the attachment will be created from that file.\nconst attachment = await collection.newAttachment(myImageBytes, metadata)\n\nconst docID = await collection.upsert({ some: 'string', my_attachment: attachment })\n\n// Later, find the document and then fetch the attachment\n\nconst doc = await collection.findByID(docID)\nconst attachmentToken = doc.at('my_attachment').attachmentToken\n\nconst attachmentFetcher = collection.fetchAttachment(attachmentToken, async (attachmentFetchEvent) => {\n switch (attachmentFetchEvent.type) {\n case 'Completed':\n const fetchedAttachment = attachmentFetchEvent.attachment\n // Do something with attachment\n break\n\n default:\n console.log('Unable to fetch attachment')\n break\n }\n})\n\n// There is also a more convenient way of fetching the attachment\n// (AttachmentFetcher implements the `PromiseLike` protocol):\nconst fetchedAttachment = await collection.fetchAttachment(attachmentToken)\n// Do something with attachment\n\n", @@ -188,7 +188,7 @@ "query-sort": "var sortedCars = ditto.Store.Collection(\"cars\")\n .Find(\"color == 'red'\")\n .Sort(\"miles\", direction: DittoSortDirection.Ascending)\n .Exec();\n\n", "query-limit": "var sortedAndLimitedRedCars = ditto.Store.Collection(\"cars\")\n .Find(\"color == 'red'\")\n .Sort(\"miles\", direction: DittoSortDirection.Ascending)\n .Limit(100).Exec();\n\n", "subscribe": "// --- Register live query to update UI\nvar subscription = ditto.Store.Collection(\"cars\").Find(\"color == 'red'\")\n .Subscribe();\n\n", - "sync-observe": "// --- Register live query to update UI\nvar liveQuery = ditto.Store.Collection(\"cars\").Find(\"color == 'red'\")\n .Observe((docs, dittoLiveQueryEvent) =>\n{\n // Do something...\n});\n\n// --- Register live query to update UI\nvar localLiveQuery = ditto.Store.Collection(\"cars\").Find(\"color == 'red'\").ObserveLocal((docs, dittoLiveQueryEvent) =>\n{\n // Do something...\n});\n\n", + "sync-observe": "// --- Register live query to update UI\nvar liveQuery = ditto.Store.Collection(\"cars\").Find(\"color == 'red'\")\n .ObserveLocal((docs, dittoLiveQueryEvent) =>\n{\n // Do something...\n});\n\n// --- Register live query to update UI\nvar localLiveQuery = ditto.Store.Collection(\"cars\").Find(\"color == 'red'\").ObserveLocal((docs, dittoLiveQueryEvent) =>\n{\n // Do something...\n});\n\n", "sync-observe-local": "// --- Register live query to update UI\nvar localLiveQuery = ditto.Store.Collection(\"cars\").Find(\"color == 'red'\")\n .ObserveLocal((docs, dittoLiveQueryEvent) =>\n{\n // Do something...\n});\n\n", "network-remote-ditto": "DittoTransportConfig transportConfig = new DittoTransportConfig();\n// Connect explicitly to a remote device on\ntransportConfig.Connect.TcpServers.Add(\"135.1.5.5:12345\");\n// you can add as many TcpServers as you would like.\ntransportConfig.Connect.TcpServers.Add(\"185.1.5.5:4567\");\n// set the transport config\nDitto.TransportConfig = transportConfig;\n// now you can start ditto's sync\nDitto.StartSync();\n\n", "network-listen": "DittoTransportConfig transportConfig = new DittoTransportConfig();\ntransportConfig.Listen.Tcp = new DittoTcpListenConfig();\n// By default Listen.Tcp.Enabled is false, be sure to set it to true.\ntransportConfig.Listen.Tcp.Enabled = true;\n// if you want to listen on localhost, most likely you will use 0.0.0.0\n// do not use \"localhost\" as a string\ntransportConfig.Listen.Tcp.InterfaceIp = \"0.0.0.0\";\n// specify your port.\ntransportConfig.Listen.Tcp.Port = 4000;\nDitto.TransportConfig = transportConfig;\n\n// now you can call `ditto.StartSync()`\nDitto.StartSync();\n\n", @@ -215,7 +215,7 @@ "query-sort": "val sortedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", DittoSortDirection.Ascending)\n .exec()\n\n", "query-limit": "val sortedAndLimitedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", DittoSortDirection.Ascending)\n .limit(100)\n .exec()\n\n", "sync-basic": "try {\n ditto.startSync()\n}\ncatch (e: DittoError) {\n // handle error\n}\n\n", - "sync-observe": "// --- DittoRegister live query to update UI\nval liveQuery = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .observe { docs, event ->\n // Do something...\n }\n\n", + "sync-observe": "// --- DittoRegister live query to update UI\nval liveQuery = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .observeLocal { docs, event ->\n // Do something...\n }\n\n", "sync-observe-local": "// --- Action somewhere in your application\nfun userDidInsertCar() {\n ditto.store.collection(\"cars\").upsert(mapOf(\n \"model\" to \"Ford\",\n \"color\" to \"black\"\n ))\n}\n\n// --- DittoRegister live query to update UI\nval observeLocalQuery = ditto.store.collection(\"cars\")\n .find(\"isSold == false\")\n .observeLocal { docs, event ->\n // Do something...\n}\n\n", "subscribe": "// --- DittoRegister live query to update UI\nval subscription = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .subscribe()\n\n", "online-playground": "try {\n val androidDependencies = DefaultAndroidDittoDependencies(context)\n val identity = DittoIdentity.OnlinePlayground(androidDependencies, appID = \"00000000-0000-4000-0000-000000000000\", token = \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\")\n val ditto = Ditto(androidDependencies, identity)\n ditto.startSync()\n} catch(e: DittoError) {\n Log.e(\"Ditto error\", e.message!!)\n}\n\n", @@ -225,7 +225,7 @@ "network-listen": "val transportConfig = DittoTransportConfig()\ntransportConfig.connect.tcpServers.add(\"135.1.5.5:12345\")\ntransportConfig.connect.tcpServers.add(\"185.1.5.5:12345\")\nditto.startSync()\n\n", "network-multiple-transports": "val transportConfig = DittoTransportConfig()\n// 1. Enable All Peer to Peer Connections\ntransportConfig.enableAllPeerToPeer()\n// 2. Listen for incoming connections on port 4000\ntransportConfig.listen.tcp.enabled = true\ntransportConfig.listen.http.enabled = false\ntransportConfig.listen.tcp.interfaceIp = \"0.0.0.0\"\ntransportConfig.listen.tcp.port = 4000\n// 3. Connect explicitly to remote devices\ntransportConfig.connect.tcpServers.add(\"135.1.5.5:12345\")\ntransportConfig.connect.tcpServers.add(\"185.1.5.5:12345\")\n\nditto.startSync()\n\n", "network-monitor-conditions": "// ... Setting up inside an Activity\nval androidDependencies = DefaultAndroidDittoDependencies(applicationContext)\nval ditto = Ditto(androidDependencies, DittoIdentity.OnlinePlayground(androidDependencies, appID = \"REPLACE_WITH_APP_ID\", token = \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\"))\nditto.callback = this\nditto.startSync()\n\n// Now you can observe real time changes to the transport conditions:\n\nclass MainActivity : AppCompatActivity(), DittoCallback {\n\n override fun transportConditionDidChange(transportId: Long, condition: TransportCondition) {\n var toastText: String? = null\n if (condition == TransportCondition.TRANSPORT_CONDITION_BLE_DISABLED) {\n toastText = \"BLE disabled\"\n } else if (condition == TransportCondition.TRANSPORT_CONDITION_NO_BLE_CENTRAL_PERMISSION) {\n toastText = \"Permission missing for BLE\"\n } else if (condition == TransportCondition.TRANSPORT_CONDITION_NO_BLE_PERIPHERAL_PERMISSION) {\n toastText = \"Permission missing for BLE\"\n }\n toastText?.let {\n Handler(mainLooper).post {\n Toast.makeText(this, it, Toast.LENGTH_LONG).show()\n }\n }\n }\n}\n\n", - "network-query-overlap-group": "// The passenger only observes orders that they created\npassenger.store.collection(\"orders\").find(\"user_id==abc123\").observe({ docs, event ->\n // render passenger orders in a list UI\n})\n\n// Crew member devices observe orders that are open \ncrewA.store.collection(\"orders\").find(\"status == 'OPEN'\").observe({ docs, event ->\n // render all orders in a list UI\n})\ncrewB.store.collection(\"orders\").find(\"status == 'OPEN'\").observe({ docs, event ->\n // render all orders in a list UI\n})\n\nDittoExperimental.setQueryOverlapGroup(2u, crewA)\nDittoExperimental.setQueryOverlapGroup(2u, crewB)\n\ncrewA.startSync()\ncrewB.startSync()\npassenger.startSync()\n\n", + "network-query-overlap-group": "// The passenger only observes orders that they created\npassenger.store.collection(\"orders\")\n .find(\"user_id==abc123\")\n .observeLocal { docs, event ->\n // render passenger orders in a list UI\n}\n\n// Crew member devices observe all orders that everyone created\ncrewA.store.collection(\"orders\")\n .find(\"status == 'OPEN'\")\n .observeLocal { docs, event ->\n // render all orders in a list UI\n}\ncrewB.store.collection(\"orders\")\n .find(\"status == 'OPEN'\")\n .observeLocal { docs, event ->\n // render all orders in a list UI\n}\n\nDittoExperimental.setQueryOverlapGroup(2u, crewA)\nDittoExperimental.setQueryOverlapGroup(2u, crewB)\n\ncrewA.startSync()\ncrewB.startSync()\npassenger.startSync()\n\n", "network-set-priority": "DittoExperimental.setPriorityForQueryOverlapGroup(DittoConnectionPriority.High, 2u, crewA)\nDittoExperimental.setPriorityForQueryOverlapGroup(DittoConnectionPriority.High, 2u, crewB)\n\n", "remove-id": "coll.findByID(docID).remove()\n\n", "remove-query": "val removedDocIDs = coll.find(\"make == 'Honda'\").remove()\n\n" @@ -262,4 +262,4 @@ "network-multiple-transports": "DittoTransportConfig config = new DittoTransportConfig();\n\n// 1. Enable Peer to Peer Connections\nconfig.enableAllPeerToPeer();\n\n// 2. Listen for incoming connections on port 4000\nDittoListen listen = new DittoListen();\nDittoTcpListenConfig tcpListenConfig = new DittoTcpListenConfig();\ntcpListenConfig.setEnabled(true);\ntcpListenConfig.setInterfaceIp(\"0.0.0.0\");\ntcpListenConfig.setPort(4000);\nlisten.setTcp(tcpListenConfig);\nconfig.setListen(listen);\n// 3. Connect explicitly to remote devices\nDittoConnect connect = new DittoConnect();\nconnect.setTcpServers(Sets.newHashSet(\"135.1.5.5:12345\", \"185.1.5.5:12345\"));\nconfig.setConnect(connect);\n\ntry {\n ditto.startSync();\n} catch(DittoError error) {\n // handle error\n}\n\n", "network-monitor-conditions": "// Setting up inside an Activity\nDefaultAndroidDittoDependencies androidDependencies = new DefaultAndroidDittoDependencies(getApplicationContext());\nDitto ditto = new Ditto(androidDependencies, new DittoIdentity.OnlinePlayground(androidDependenciesOne, \"REPLACE_WITH_APP_ID\"));\nditto.callback = this;\nditto.startSync();\n\n// Now you can observe real time changes to the transport conditions:\npublic class MainActivity extends AppCompatActivity implements DittoCallback {\n @Override\n public void transportConditionDidChange(@NotNull DittoTransportCondition condition, @NotNull DittoConditionSource transportId) {\n String toastText = null;\n if (condition == DittoTransportCondition.BleDisabled) {\n toastText = \"BLE disabled\";\n } else if (condition == DittoTransportCondition.NoBleCentralPermission) {\n toastText = \"Permission missing for BLE\";\n } else if (condition == DittoTransportCondition.NoBlePeripheralPermission) {\n toastText = \"Permission missing for BLE\";\n }\n\n if (toastText != null) {\n String finalToastText = toastText;\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n Toast.makeText(MainActivity.this, finalToastText, Toast.LENGTH_LONG).show();\n }\n });\n }\n }\n}\n\n" } -} \ No newline at end of file +}