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

How to subscribe on collection updates? #139

Open
markobabych opened this issue May 9, 2020 · 4 comments
Open

How to subscribe on collection updates? #139

markobabych opened this issue May 9, 2020 · 4 comments

Comments

@markobabych
Copy link

I tried to use add_callback, but it works only to monitor specific records. I tried to add callbacks to collection-views and specific collections and then manually refresh records to have a callback.

Does someone know how to monitor collection updates?

@midnightmastermind
Copy link

I would like to know this as well :)

@000namc
Copy link

000namc commented Jun 2, 2020

Same part's hard for me.
add_callback only works to monitor " notion.block.CollectionViewPageBlock " not " notion.collection.CollectionRowBlock ".
All I want is to subscribes all the changes in each card in database.
Does someone know about it?

@ekopach
Copy link

ekopach commented Jun 4, 2020

It seems that in the NotionClinet you need to add the parameter start_monitoring=True.
At least this works for me, my code is:

from notion.client import NotionClient
client = NotionClient(token_v2="<your token>",monitor=True,start_monitoring=True,enable_caching=False)

def watch_completed_milestones():
	cv = client.get_collection_view(
		"<your notion db link>"
	)

	def my_callback(record, difference):
		print("The record's title is now:", record.title)
		print("Here's what was changed:")
		print(difference)

	for block_row in cv.collection.get_rows():
		print("Adding callback for:", block_row.title)
		block_row.add_callback(my_callback)

watch_completed_milestones()

print("Ready and watching!")

input()

`
I took it here #12 (comment) and the parameter found in the sources.

@ThallyssonKlein
Copy link

Is it possible to monitor for new items added to the collection?

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

No branches or pull requests

5 participants