diff --git a/app/views/docs/getting-started-for-android.phtml b/app/views/docs/getting-started-for-android.phtml index 3ad772ac9..8eb239fbb 100644 --- a/app/views/docs/getting-started-for-android.phtml +++ b/app/views/docs/getting-started-for-android.phtml @@ -103,7 +103,7 @@ val json = response.body?.string() val realtime = Realtime(client) realtime.subscribe("files", callback = { response -> - if(response.event == "storage.files.create") { + if(response.events.contains("buckets.*.files.*.create")) { // Log when a new file is uploaded print(response.payload.toString()); } @@ -130,7 +130,7 @@ val json = response.body?.string() val realtime = Realtime(client) realtime.subscribe("files", callback = { response -> - if(response.event == "storage.files.create") { + if(response.events.contains("buckets.*.files.*.create")) { // Log when a new file is uploaded print(response.payload.toString()); } diff --git a/app/views/docs/getting-started-for-apple.phtml b/app/views/docs/getting-started-for-apple.phtml index 83feea7cd..5fcf0e9b5 100644 --- a/app/views/docs/getting-started-for-apple.phtml +++ b/app/views/docs/getting-started-for-apple.phtml @@ -135,7 +135,7 @@ print(user.toMap()) let realtime = Realtime(client: client) let subscription = realtime.subscribe(channels: ["files"]) { message in - if(message.event == "storage.files.create") { + if(message.events!.contains("buckets.*.files.*.create")) { // Log when a new file is uploaded print(String(describing: message.payload)) } @@ -163,7 +163,7 @@ print(user.toMap()) let realtime = Realtime(client: client) let subscription = realtime.subscribe(channels: ["files"]) { message in - if(message.event == "storage.files.create") { + if(message.events!.contains("buckets.*.files.*.create")) { // Log when a new file is uploaded print(String(describing: message.payload)) } diff --git a/app/views/docs/getting-started-for-flutter.phtml b/app/views/docs/getting-started-for-flutter.phtml index 0a36aef7f..fd48b0f6f 100644 --- a/app/views/docs/getting-started-for-flutter.phtml +++ b/app/views/docs/getting-started-for-flutter.phtml @@ -173,7 +173,7 @@ final realtime = Realtime(client); final subscription = realtime.subscribe(['files']); subscription.stream.listen((response) { - if(response.event == 'storage.files.create') { + if(response.events.contains('buckets.*.files.*.create') { // Log when a new file is uploaded print(response.payload); } @@ -209,7 +209,7 @@ final realtime = Realtime(client); final subscription = realtime.subscribe(['files']); subscription.stream.listen((response) { - if(response.event == 'storage.files.create') { + if(response.events.contains('buckets.*.files.*.create')) { // Log when a new file is uploaded print(response.payload); } diff --git a/app/views/docs/getting-started-for-web.phtml b/app/views/docs/getting-started-for-web.phtml index 6fd6ccacb..abc774884 100644 --- a/app/views/docs/getting-started-for-web.phtml +++ b/app/views/docs/getting-started-for-web.phtml @@ -102,7 +102,7 @@ appwrite
// Subscribe to files channel
appwrite.subscribe('files', response => {
- if(response.event === 'storage.files.create') {
+ if(response.events.includes('buckets.*.files.*.create')) {
// Log when a new file is uploaded
console.log(response.payload);
}
@@ -130,7 +130,7 @@ appwrite
// Subscribe to files channel
appwrite.subscribe('files', response => {
- if(response.event === 'storage.files.create') {
+ if(response.events.includes('buckets.*.files.*.create')) {
// Log when a new file is uploaded
console.log(response.payload);
}
diff --git a/app/views/docs/realtime.phtml b/app/views/docs/realtime.phtml
index ba958ef2f..7917badc7 100644
--- a/app/views/docs/realtime.phtml
+++ b/app/views/docs/realtime.phtml
@@ -36,7 +36,7 @@ sdk
// Subscribe to files channel
sdk.subscribe('files', response => {
- if(response.event === 'storage.files.create') {
+ if(response.events.includes('buckets.*.files.*.create')) {
// Log when a new file is uploaded
console.log(response.payload);
}
@@ -60,7 +60,7 @@ final realtime = Realtime(client);
final subscription = realtime.subscribe(['files']);
subscription.stream.listen((response) {
- if(response.event == 'storage.files.create') {
+ if(response.events.contains('buckets.*.files.*.create')) {
// Log when a new file is uploaded
print(response.payload);
}
@@ -80,7 +80,7 @@ val realtime = Realtime(client)
// Subscribe to files channel
realtime.subscribe("files", callback = { response ->
- if(response.event === "storage.files.create") {
+ if(response.events.contains("buckets.*.files.*.create")) {
// Log when a new file is uploaded
print(response.payload.toString());
}
@@ -100,7 +100,7 @@ let realtime = Realtime(client: client)
// Subscribe to files channel
let subscription = realtime.subscribe(channels: ["files"]) { message in
- if(message.event == "storage.files.create") {
+ if(message.events!.contains("buckets.*.files.*.create")) {
// Log when a new file is uploaded
print(String(describing: message.payload))
}
@@ -111,7 +111,7 @@ let subscription = realtime.subscribe(channels: ["files"]) { message in
To subscribe to updates from different resources, you need to specify one or more channels. The channels offer a wide and powerful selection that will allow you to listen to all possible resources. This allows you to receive updates not only from the database, but from all the services that Appwrite offers.
-If you listen to all documents from a collection by subscribing to the collections.[ID].documents channel, you can use the event attribute in the callback to distinguish whether a new document was created or an existing one was updated.
+If you subscribe to a channel, you will receive callbacks for a variety of events related to the channel. The events attribute in the callback can be used to filter and respond to specific events in a channel.
All possible events can be found here.
@@ -320,13 +320,13 @@ subscription.close()
{
- "event": "database.documents.update",
+ "events": [
+ "collections.user.documents.627a95c0785cc5c7fff2.delete",
+ "collections.*.documents.*.delete",
+ "collections.user.documents.*.delete",
+ "collections.*.documents.627a95c0785cc5c7fff2.delete",
+ "collections.user.documents.627a95c0785cc5c7fff2",
+ "collections.*.documents.*",
+ "collections.user.documents.*",
+ "collections.*.documents.627a95c0785cc5c7fff2",
+ "collections.user",
+ "collections.*"
+ ],
"channels": [
"documents",
- "documents.[DOCUMENT_ID]",
- "collections.[COLLECTION_ID].documents"
+ "collections.user.documents",
+ "collections.user.documents.627a95c0785cc5c7fff2"
],
- "timestamp": 1629719169,
+ "timestamp": 1653957271,
"payload": {
- "$id": "[DOCUMENT_ID]",
- "$collection": "[COLLECTION_ID]",
- "$permissions": [],
- "attribute1": "lorem",
- "attribute2": 2030
+ "field1": "lorem ipsum",
+ "field2": [],
+ "$read": [
+ "user:627a958ded6424a98a9f"
+ ],
+ "$write": [
+ "user:627a958ded6424a98a9f"
+ ],
+ "$id": "627a95c0785cc5c7fff2",
+ "$collection": "example-collection"
}
}