<commit_before>export default function (provider, reduxStore, actions) {
  const providerApi = {
    onStory(cb) {
      providerApi._onStoryCallback = cb;
    },

    addAction: actions.api.addAction,
    setStories: actions.api.setStories,
    selectStory: actions.api.selectStory,
    handleShortcut: actions.shortcuts.handleEvent,
  };

  provider.handleAPI(providerApi);

  // subscribe to redux store and trigger onStory's callback
  reduxStore.subscribe(function () {
    const { api } = reduxStore.getState();
    if (!api) return;

    providerApi._onStoryCallback(api.selectedKind, api.selectedStory);
  });
}
<commit_msg>Make sure api.onStory has been called or not.<commit_after>export default function (provider, reduxStore, actions) {
  const providerApi = {
    onStory(cb) {
      providerApi._onStoryCallback = cb;
    },

    addAction: actions.api.addAction,
    setStories: actions.api.setStories,
    selectStory: actions.api.selectStory,
    handleShortcut: actions.shortcuts.handleEvent,
  };

  provider.handleAPI(providerApi);

  // subscribe to redux store and trigger onStory's callback
  reduxStore.subscribe(function () {
    const { api } = reduxStore.getState();
    if (!api) return;
    if (!providerApi._onStoryCallback) return;
    
    providerApi._onStoryCallback(api.selectedKind, api.selectedStory);
  });
}

{'fraction_non_alphanumeric': 0.1091314031180401, 'fraction_numerical': 0.0, 'mean_word_length': 3.8840579710144927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4369432', 'n_tokens_mistral': 429, 'n_tokens_neox': 399, 'n_words': 84}