Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/views/docs/getting-started-for-android.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ val json = response.body?.string()</code></pre>
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());
}
Expand All @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/docs/getting-started-for-apple.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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))
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/docs/getting-started-for-flutter.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/docs/getting-started-for-web.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ appwrite
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
<pre class="line-numbers"><code class="prism language-javascript" data-prism>// 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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
50 changes: 33 additions & 17 deletions app/views/docs/realtime.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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());
}
Expand All @@ -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))
}
Expand All @@ -111,7 +111,7 @@ let subscription = realtime.subscribe(channels: ["files"]) { message in

<p>To subscribe to updates from different resources, you need to specify one or more channels. The <a href="/docs/realtime#channels">channels</a> 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.</p>

<p>If you listen to all documents from a collection by subscribing to the <span class="tag">collections.[ID].documents</span> channel, you can use the <b>event</b> attribute in the callback to distinguish whether a new document was created or an existing one was updated.</p>
<p>If you subscribe to the a channel, you will receive callbacks for a variety of events related to the channel. The <b>events</b> attribute in the callback can be used to filter and respond to specific events in a channel.</p>

<p>All possible events can be found <a href="/docs/webhooks#events">here</a>.</p>

Expand Down Expand Up @@ -320,13 +320,13 @@ subscription.close()</code></pre>
<tbody>
<tr>
<td data-title="Name: ">
event
events
</td>
<td data-title="Type: ">
string
string[]
</td>
<td data-title="Description: ">
The <a href="/docs/webhooks#events">system event</a> that triggered this update.
The <a href="/docs/webhooks#events">system events</a> that triggered this update.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do we only have events documented under webhooks? How do people using Functions learn about all the events? This might be a concern for separate task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need to review this. Let me open a separate task for this.

</td>
</tr>
<tr>
Expand Down Expand Up @@ -371,19 +371,35 @@ subscription.close()</code></pre>

<div class="ide margin-bottom" data-lang="json" data-lang-label="JSON">
<pre class="line-numbers"><code class="prism language-json" data-prism>{
"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"
}
}</code></pre>
</div>
Expand Down