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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(createEventHook): allow trigger to optionally have no parameters #3507

Merged
merged 1 commit into from
Nov 9, 2023

Commits on Oct 27, 2023

  1. feat(createEventHook): allow trigger to optionally have no parameters

    Previously, `createEventHook()`'s `trigger()` would always require at
    least one parameter:
    
    ```ts
    const { trigger } = createEventHook();
    
    trigger();
    //      ^
    // TypeScript error: Expected 1 arguments, but got 0
    ```
    
    Now, parameters are optional. This allows a use case where there is no
    other information to send when triggering an event, and simply knowing
    that an event was triggered is all that is needed:
    
    ```ts
    const { on, trigger } = createEventHook();
    
    // This is now possible:
    trigger(/* having no arguments is now allowed */);
    
    // Elsewhere, we can listen for the event:
    on((/* no arguments */) => {})
    ```
    curtgrimes committed Oct 27, 2023
    Configuration menu
    Copy the full SHA
    251b985 View commit details
    Browse the repository at this point in the history