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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate concern of UI and flow #10

Open
gasolin opened this issue Oct 16, 2016 · 1 comment
Open

separate concern of UI and flow #10

gasolin opened this issue Oct 16, 2016 · 1 comment

Comments

@gasolin
Copy link
Owner

gasolin commented Oct 16, 2016

use sort of redux pattern (dispatch->reducer) and host state to reflect any change.

@gasolin gasolin added this to the Saaroa milestone Mar 2, 2017
@gasolin
Copy link
Owner Author

gasolin commented Mar 2, 2017

What we have now (wikipedia plugin for example)

SaihuBot.prototype.responses.push({
  name: 'wikipedia',
  help: 'wikipedia|w|wiki [term] - search wikipedia with [term]',
  rule: /(^wikipedia |^w |^wiki )(.*)/i,
  action: function(robot, msg) {
    let url = 'http://en.wikipedia.org/w/index.php?title=Special:Search&search=' + encodeURIComponent(msg[2]);
    let link = renderResponse('Search', msg[2], url, 'Wikipedia');
    robot.adapter.sendHTML(link);
    openTab(url);
  },
});

The rule and actions are all saved in responses[], we can treat this as the shorthand definition, and save rules, name, actions into different place. Ex:

  • save name(id) to intents[]
  • save rule to rules[],
  • save action to reducers[]

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

No branches or pull requests

1 participant