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

Implement App/User Listener #5080

Merged
merged 2 commits into from
Nov 9, 2022
Merged

Implement App/User Listener #5080

merged 2 commits into from
Nov 9, 2022

Conversation

takameyer
Copy link
Contributor

@takameyer takameyer commented Nov 7, 2022

What, How & Why?

Used the subscribe and unsubscribe methods to finish the app and user listener implementation.

This closes #5062

☑️ ToDos

  • 📝 Changelog entry
  • 📝 Compatibility label is updated or copied from previous entry
  • 📝 Update COMPATIBILITY.md
  • 🚦 Tests
  • 🔀 Executed flexible sync tests locally if modifying flexible sync
  • 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • 📱 Check the React Native/other sample apps work if necessary
  • 📝 Public documentation PR created or is not necessary
  • 💥 Breaking label has been applied or is not necessary

If this PR adds or changes public API's:

  • typescript definitions file is updated
  • jsdoc files updated

Used the `subscribe` and `unsubscribe` methods to finish the app listener implementation.
@cla-bot cla-bot bot added the cla: yes label Nov 7, 2022
@takameyer takameyer marked this pull request as ready for review November 7, 2022 11:11
@takameyer takameyer changed the title Finish App Listener Implement App/User Listener Nov 7, 2022
Comment on lines 73 to 76
private listeners = new Listeners<AppChangeCallback, AppListenerToken, [binding.App]>({
register(callback: () => void, internal: binding.App): AppListenerToken {
const token = internal.subscribe(callback);
return { internal, token };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion on this when we went through it on the call. It shouldn't be needed to include the App internal into the token, since you can simple read it off the SDK App instance using this.internal.

Suggested change
private listeners = new Listeners<AppChangeCallback, AppListenerToken, [binding.App]>({
register(callback: () => void, internal: binding.App): AppListenerToken {
const token = internal.subscribe(callback);
return { internal, token };
private listeners = new Listeners<AppChangeCallback, binding.AppSubscriptionToken>({
register(callback: () => void): binding.AppSubscriptionToken {
return this.internal.subscribe(callback);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed now. Needed to convert this into an arrow function so that the App context was binded to this.

@@ -68,6 +74,16 @@ export class User<
/** @internal */
public internal: binding.SyncUser;

private listeners = new Listeners<UserChangeCallback, UserListenerToken, [binding.SyncUser]>({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as with the App .. you should be able to get the relevant binding.SyncUser via this.internal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed

@takameyer takameyer merged commit ec2b74f into bindgen Nov 9, 2022
@takameyer takameyer deleted the andrew/applistener branch November 9, 2022 10:07
RedBeard0531 pushed a commit that referenced this pull request Nov 15, 2022
* Finish App Listener

Used the `subscribe` and `unsubscribe` methods to finish the app listener implementation.

* Implement user listeners
RedBeard0531 pushed a commit that referenced this pull request Nov 23, 2022
* Finish App Listener

Used the `subscribe` and `unsubscribe` methods to finish the app listener implementation.

* Implement user listeners
takameyer added a commit that referenced this pull request Dec 28, 2022
* Finish App Listener

Used the `subscribe` and `unsubscribe` methods to finish the app listener implementation.

* Implement user listeners
kraenhansen pushed a commit that referenced this pull request Mar 1, 2023
* Finish App Listener

Used the `subscribe` and `unsubscribe` methods to finish the app listener implementation.

* Implement user listeners
kraenhansen pushed a commit that referenced this pull request Mar 3, 2023
* Finish App Listener

Used the `subscribe` and `unsubscribe` methods to finish the app listener implementation.

* Implement user listeners
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants