Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FredrikOseberg/e7cf680241fadc5fe9ff765df78f272f to your computer and use it in GitHub Desktop.
Save FredrikOseberg/e7cf680241fadc5fe9ff765df78f272f to your computer and use it in GitHub Desktop.
class ActionProvider {
// The action provider receives createChatBotMessage which you can use to define the bots response, and
// the setState function that allows for manipulating the bots internal state.
constructor(createChatBotMessage, setStateFunc, createClientMessage) {
this.createChatBotMessage = createChatBotMessage;
this.setState = setStateFunc;
this.createClientMessage = createClientMessage
}
reset = () => {
this.setState(prev => ({ ...prev, messages: [this.createChatbotMessage("Hi")] }))
}
export default ActionProvider;
@lewis-Hope
Copy link

How can I extend the ActionProvider class to another class to use it many times?
Here's the code that I'm working on, but still I get an error.

import ActionProvider from "./ActionProvider";

class ResponseProvider extends ActionProvider {

constructor(props) {

    super(props);
    this.createChatBotMessage = props.createChatBotMessage;
    this.setState = props.setStateFunc;

}

greeter = () =>{
    const message = this.createChatBotMessage("Hello!, This is inheritance test");
    this.addMessageToState(message);
};

}

export default ResponseProvider;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment