Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 936 Bytes

how-to-use.md

File metadata and controls

34 lines (28 loc) · 936 Bytes

How to Use

Here are the basics of how to use callbacks and expose functions from the plugin. You can see the list of APIs in this API reference.

Expose functions

To access the expose functions, you will need to use the service tawkMessenger. In your component, controller or anywhere you want to access the functions, simply call the service in your JavaScript file.

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';

export default class MyComponent extends Component {
    @service('tawk-messenger') tawkMessenger;

    @action
    handleToggle() {
        this.tawkMessenger.toggle();
    }
}

Using Callbacks

In your handlebar component, Add TawkMessenger as a component and pass a function as value of the props.

<div>
    <TawkMessenger
        @onLoad={{this.handleToggle}}/>
</div>