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

yffi: observer callbacks do not supply the transaction origin #497

Open
britannio opened this issue Sep 14, 2024 · 2 comments · May be fixed by #498
Open

yffi: observer callbacks do not supply the transaction origin #497

britannio opened this issue Sep 14, 2024 · 2 comments · May be fixed by #498

Comments

@britannio
Copy link

I'm working on a y-crdt port to Dart (https://github.com/britannio/y_dart) but the lack of an origin in observe callbacks makes it more challenging to implement bindings for storage and text editing.

My current solution introduces a transaction_origin_data() function copied from YUndoEvent.new
https://github.com/britannio/y_dart/blob/044c6d5f1022fcbbe7d21d342297fa24a07645a6/rust/src/lib.rs#L510-L544

@Horusiath
Copy link
Collaborator

Most of the observe callbacks come with TransactionMut as one of the callback parameters. Have you tried to call TransactionMut::origin?

@britannio
Copy link
Author

Most of the observe callbacks come with TransactionMut as one of the callback parameters. Have you tried to call TransactionMut::origin?

The function I introduced uses TransactionMut::origin and converts it to (*const c_char, u32) which can be passed over ffi to Dart.

Another solution would be to pass the transaction to the callback and introduce a ffi (extern C) function to convert *TransactionMut to (*const c_char, u32) with the origin data but that requires extra calls over the ffi boundary.

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 a pull request may close this issue.

2 participants