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

Missing transaction in Python event #232

Open
fcollonval opened this issue Feb 17, 2025 · 1 comment · May be fixed by #233
Open

Missing transaction in Python event #232

fcollonval opened this issue Feb 17, 2025 · 1 comment · May be fixed by #233
Labels
enhancement New feature or request

Comments

@fcollonval
Copy link
Member

Description

The API of Yjs for event lists an attribute transaction to events. That attribute is defined in Rust but not accessible in Python as not listed in the slots.

Reproduce

In [1]: from pycrdt import Array, Doc, Map, Text

In [2]:     text = Text()
   ...:     array = Array()
   ...:     map_ = Map()
   ...:     Doc(
   ...:         {
   ...:             "text": text,
   ...:             "array": array,
   ...:             "map": map_,
   ...:         }
   ...:     )
   ...:     events = []

In [3]: def callback(event):
   ...:     print(event)
   ...:     print(event.transaction)

In [4]:     sub0 = text.observe(callback)  # noqa: F841
   ...:     sub1 = array.observe(callback)  # noqa: F841
   ...:     sub2 = map_.observe(callback)  # noqa: F841
   ...:     with text.doc.transaction():
   ...:         text += "hello"
   ...:         text += " world"
   ...:     array.append(1)
   ...:     map_["foo"] = "bar"

This will failed.

Expected behavior

No failure

Context

Version 0.10.9

@fcollonval fcollonval added the bug Something isn't working label Feb 17, 2025
@fcollonval fcollonval changed the title Missing transaction in Pyton event Missing transaction in Python event Feb 17, 2025
@davidbrochart
Copy link
Collaborator

I wouldn't label it as a bug but as a feature request.
Would you like to open a PR?

@fcollonval fcollonval linked a pull request Feb 17, 2025 that will close this issue
@davidbrochart davidbrochart added enhancement New feature or request and removed bug Something isn't working labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants