Options
All
  • Public
  • Public/Protected
  • All
Menu

The event emitter for stack changes. Can be used to understand the state of the navigation

example
Determine current screen ```ts import { stackEventEmitter, StackEvent, IStackDataImmutable, getScreenName, StackOnChange, } from '@ef-carbon/react-native-navigation';

const callback: StackOnChange = ({ screen }) => console.log(getScreenName(screen));

// Add listener, usually done in the application container componentDidMount stackEventEmitter.addListener(StackEvent.Change, callback);

// Remove the listener, usually done in the application container componentWillUnmount stackEventEmitter.removeListener(StackEvent.Change, callback); `

Hierarchy

  • IStackEventEmitter

Implemented by

Index

Methods

addListener

  • addListener(event: Event.Change, callback: OnChange): void
  • addListener(event: Event.Push, callback: OnPush): void
  • addListener(event: Event.Pop, callback: OnPop): void
  • addListener(event: Event.Reset, callback: OnReset): void
  • addListener(event: Event.Replace, callback: OnReplace): void

removeListener

  • removeListener(event: Event.Change, callback: OnChange): void
  • removeListener(event: Event.Push, callback: OnPush): void
  • removeListener(event: Event.Pop, callback: OnPop): void
  • removeListener(event: Event.Reset, callback: OnReset): void
  • removeListener(event: Event.Replace, callback: OnReplace): void
  • Removes the event listener from the emitter

    Parameters

    • event: Event.Change

      the "change" event name

    • callback: OnChange

      the StackOnChange callback function that was added through addListener

    Returns void

  • Removes the event listener from the emitter

    Parameters

    • event: Event.Push

      the "change" event name

    • callback: OnPush

      the StackOnPush callback function

    Returns void

  • Removes the event listener from the emitter

    Parameters

    • event: Event.Pop

      the "change" event name

    • callback: OnPop

      the StackOnPop callback function

    Returns void

  • Removes the event listener from the emitter

    Parameters

    • event: Event.Reset

      the "change" event name

    • callback: OnReset

      the StackOnReset callback function

    Returns void

  • Removes the event listener from the emitter

    Parameters

    • event: Event.Replace

      the "change" event name

    • callback: OnReplace

      the StackOnReplace callback function

    Returns void