-
Notifications
You must be signed in to change notification settings - Fork 165
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
expose sync user subscribe in the c-api #7302
Conversation
c24d7d4
to
d743f57
Compare
d743f57
to
20bc08a
Compare
Pull Request Test Coverage Report for Build nicola.cabiddu_1344
💛 - Coveralls |
b021e56
to
560155a
Compare
test/object-store/c_api/c_api.cpp
Outdated
@@ -615,6 +615,9 @@ TEST_CASE("C API (non-database)", "[c_api]") { | |||
}, | |||
&sync_user, user_data_free); | |||
|
|||
auto user_state = [](realm_userdata_t, realm_user_state_e) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should check the user logs in (and other state changes)
src/realm.h
Outdated
|
||
// register callback for tracking user status. | ||
RLM_API realm_user_subscription_token_t* | ||
realm_user_state_change_register_callback(realm_user_t*, realm_user_changed_callback_t, realm_userdata_t userdata, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
realm_sync_user_register_state_changed_callback?
src/realm.h
Outdated
typedef struct realm_async_open_task_progress_notification_token realm_async_open_task_progress_notification_token_t; | ||
typedef struct realm_sync_session_connection_state_notification_token | ||
realm_sync_session_connection_state_notification_token_t; | ||
typedef struct realm_user_subscription_token realm_user_subscription_token_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sync_user
src/realm.h
Outdated
@@ -3495,9 +3495,13 @@ typedef enum realm_flx_sync_subscription_set_state { | |||
typedef void (*realm_sync_on_subscription_state_changed_t)(realm_userdata_t userdata, | |||
realm_flx_sync_subscription_set_state_e state); | |||
|
|||
typedef void (*realm_user_changed_callback_t)(realm_userdata_t userdata, realm_user_state_e s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
realm_sync_user_state_changed_t?
CHANGELOG.md
Outdated
@@ -2,6 +2,7 @@ | |||
|
|||
### Enhancements | |||
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????)) | |||
* Add support in the C API for receiving a notification when sync user status changes. ([#7302](https://github.com/realm/realm-core/pull/7302)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: status -> state
src/realm.h
Outdated
@@ -3894,6 +3898,12 @@ RLM_API realm_sync_session_connection_state_notification_token_t* realm_sync_ses | |||
realm_sync_session_t*, realm_sync_progress_func_t, realm_sync_progress_direction_e, bool is_streaming, | |||
realm_userdata_t userdata, realm_free_userdata_func_t userdata_free) RLM_API_NOEXCEPT; | |||
|
|||
|
|||
// register callback for tracking user status. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// @return a notification token object. Dispose it to stop receiving notifications.
src/realm.h
Outdated
@@ -3495,9 +3495,13 @@ typedef enum realm_flx_sync_subscription_set_state { | |||
typedef void (*realm_sync_on_subscription_state_changed_t)(realm_userdata_t userdata, | |||
realm_flx_sync_subscription_set_state_e state); | |||
|
|||
typedef void (*realm_user_changed_callback_t)(realm_userdata_t userdata, realm_user_state_e s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if realm_user_t*
should be an argument to be able to easily distinguish between different user notifications. I guess realm_userdata_t
could be used for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the sdks can pass whatever they want in there.
bindgen spec exposes |
There is no C-API in the bingen (AFAIK), also all the tokens that we expose are destroyed via |
I meant that you can unregister if you don't use the c-api, and I was thinking how well they both should align (I agree we have different patterns in the c-api, such as stopping notifications if the token is destroyed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What, How & Why?
Fixes: #7301
☑️ ToDos
bindgen/spec.yml
, if public C++ API changed