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

Observer's subscription ID shouldn't be required #23

Closed
davidbrochart opened this issue Apr 4, 2022 · 0 comments
Closed

Observer's subscription ID shouldn't be required #23

davidbrochart opened this issue Apr 4, 2022 · 0 comments

Comments

@davidbrochart
Copy link
Collaborator

davidbrochart commented Apr 4, 2022

In the following code we register a callback for an observer and don't keep a reference to the subscription ID:

import y_py as Y

d = Y.YDoc()

def callback(e):
    print(e)

x = d.get_text("test")

def register_cb(x, callback):
    i = x.observe(callback)
    # if i is not returned, the callback will never be called
    # return i  # this works fine (callback called)

i = register_cb(x, callback)

with d.begin_transaction() as txn:
    x.insert(txn, 0, "abcd")

This can happen when we don't want to unobserve. But the issue is that in this case the callback is never called.

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

2 participants