Skip to content

Commit

Permalink
Add header comment blocks to new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
takameyer committed May 4, 2022
1 parent 61d1b40 commit 448de72
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/js_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,15 @@ void AppClass<T>::set_versions(ContextType ctx, ObjectType this_object, Argument
AppClass<T>::platform_os = Object::validated_get_string(ctx, versions, "platformOs");
AppClass<T>::platform_version = Object::validated_get_string(ctx, versions, "platformVersion");
}

/**
* @brief Registers an event listener on the SharedApp that fires on various app events.
* This includes login, logout, switching users, linking users and refreshing custom data.
*
* @param ctx JS context
* @param this_object JS's object holding the `AppClass`
* @param args Contains a callback that will be called on an event
* @param return_value \ref void
*/
template <typename T>
void AppClass<T>::add_listener(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value)
{
Expand All @@ -402,6 +410,14 @@ void AppClass<T>::add_listener(ContextType ctx, ObjectType this_object, Argument
NotificationBucket::emplace(app->m_notification_handle, std::move(protected_callback), std::move(token));
}

/**
* @brief Removes the event listener for the provided callback.
*
* @param ctx JS context
* @param this_object JS's object holding the `AppClass`
* @param args Contains a callback function that was given to `addListener`
* @param return_value \ref void
*/
template <typename T>
void AppClass<T>::remove_listener(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value)
{
Expand All @@ -413,6 +429,14 @@ void AppClass<T>::remove_listener(ContextType ctx, ObjectType this_object, Argum
NotificationBucket::erase(app->m_notification_handle, std::move(protected_callback));
}

/**
* @brief Removes all registered event listeners.
*
* @param ctx JS context
* @param this_object JS's object holding the `AppClass`
* @param args No arguments
* @param return_value \ref void
*/
template <typename T>
void AppClass<T>::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments& args,
ReturnValue& return_value)
Expand Down
25 changes: 25 additions & 0 deletions src/js_user.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ void UserClass<T>::new_watch_stream(ContextType ctx, ObjectType this_object, Arg
return return_value.set(create_object<T, WatchStreamClass<T>>(ctx, new WatchStream()));
}

/**
* @brief Registers an event listener on the SharedApp that fires on various user events.
* This includes auth token refresh, refresh token refresh, refresh custom user data, and logout.
*
* @param ctx JS context
* @param this_object JS's object holding the `UserClass`
* @param args Arguments passed to `addListener()` from JS
* @param return_value \ref void
*/
template <typename T>
void UserClass<T>::add_listener(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value)
{
Expand All @@ -514,6 +523,14 @@ void UserClass<T>::add_listener(ContextType ctx, ObjectType this_object, Argumen
NotificationBucket::emplace(user->m_notification_handle, std::move(protected_callback), std::move(token));
}

/**
* @brief Removes the event listener for the provided callback.
*
* @param ctx JS context
* @param this_object JS's object holding the `UserClass`
* @param args Contains a callback function that was given to
* @param return_value \ref void
*/
template <typename T>
void UserClass<T>::remove_listener(ContextType ctx, ObjectType this_object, Arguments& args,
ReturnValue& return_value)
Expand All @@ -526,6 +543,14 @@ void UserClass<T>::remove_listener(ContextType ctx, ObjectType this_object, Argu
NotificationBucket::erase(user->m_notification_handle, std::move(protected_callback));
}

/**
* @brief Removes all registered event listeners.
*
* @param ctx JS context
* @param this_object JS's object holding the `UserClass`
* @param args No arguments
* @param return_value \ref void
*/
template <typename T>
void UserClass<T>::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments& args,
ReturnValue& return_value)
Expand Down

0 comments on commit 448de72

Please sign in to comment.