Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add collection subscribe support #11

Merged
merged 4 commits into from
Dec 12, 2022
Merged

Conversation

shynome
Copy link
Contributor

@shynome shynome commented Dec 11, 2022

This pr is based on the last pr generic collection support

simple usage example, don't deal error

package main

import (
	"log"

	"github.com/r--w/pocketbase"
)

func main() {
	client := pocketbase.NewClient("http://localhost:8090")
	collection := pocketbase.CollectionSet[map[string]any](client, "posts_public")

	stream, err := collection.Subscribe()
        defer stream.Unsubscribe()
	err = stream.WaitAuthReady() // This step is required, the subscribe target maybe is error

	for ev := range stream.Events() {
		log.Print(ev.Action, ev.Record)
	}
}

@r--w
Copy link
Owner

r--w commented Dec 11, 2022

Hi @shynome thats great contribution, can you fix the linter suggestions before I do the review?

@shynome
Copy link
Contributor Author

shynome commented Dec 11, 2022

This time I ran make check before committing and it fixed the linter suggestion

@r--w r--w mentioned this pull request Dec 12, 2022
r--w and others added 3 commits December 12, 2022 14:32
@r--w r--w merged commit fecbdcf into r--w:master Dec 12, 2022
@r--w
Copy link
Owner

r--w commented Dec 12, 2022

This closes #7
thank you @shynome, I made some minor changes hope you don't mind

@shynome
Copy link
Contributor Author

shynome commented Dec 12, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants