Skip to content

BuildFire Toast Component

o5faruk edited this page May 2, 2021 · 4 revisions

⚠️⚠️⚠️

This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/toast/

⚠️⚠️⚠️

buildfire.components.toast

The toast component provides brief, contextual messages about app processes at the bottom of the screen. Each toast message contains a message and an optional action.

This component only functions on the widget!

Requirements

The following must be included in the index.html file of the widget or service.

  <script src="../../../scripts/buildfire.min.js"></script>
  <script src="../../../scripts/buildfire/components/toast/toast.js"></script>

showToastMessage(options, callback)

This method is used to show a toast message. The toast will automatically close after a short time.

options

The options object can contain the following:

  • text: String, required. This renders as the message of the toast
  • action: Object, optional
    • title: Renders as the action button text.
    • action can contain any optional data to be handled when that action button is clicked.
    • See How to use action items for action item support
    • When the action is clicked, the action is returned in the callback.
  • hideDismiss: Boolean, optional. If true, the dismiss button is hidden from the modal.

callback(error, result)

The callback function is executed when the user takes an action, or an error occurs.

  • error: Any errors that occur
  • result: The action passed to options.action is returned if the user clicks the action button

Example

const options = {
  text: 'User added to Favorites',
  action: {
    title: 'Undo',
    userId: 'fb942c43e9'
  }
};

const callback = (error, result) => {
  if (error) throw error;

  if (result.userId) {
    Favorites.remove(userId);
  }
};

buildfire.components.toast.showToastMessage(options, callback);

closeToastMessage(options, callback)

This method is used to close toast message. The toast will close itself after a short time, or if options.force is passed it will close immediately.

options

The options object can contain the following:

  • force: Boolean, optional. If true, the toast will close immediately.

callback(error)

The callback function is executed when the closing action is successfully registered.

  • error: Any errors that occur

Clone this wiki locally