const Reflux = require('reflux');
const {{pascalcase name}}Actions = require('../actions');
const StateMixin = require('reflux-state-mixin');
const { DataServiceStore } = require('mongodb-data-service');

const debug = require('debug')('mongodb-compass:stores:{{slugcase name}}');

/**
 * {{capitalcase name}} store.
 */

const {{pascalcase name}}Store = Reflux.createStore({
  /**
   * adds a state to the store, similar to React.Component's state
   * @see https://github.com/yonatanmn/Super-Simple-Flux#reflux-state-mixin
   */
  mixins: [StateMixin.store],

  /**
   * listen to all actions defined in ../actions/index.jsx
   */
  listenables: {{pascalcase name}}Actions,

  /**
   * Initialize everything that is not part of the store's state.
   */
  init() {
    DataServiceStore.listen((error, dataService) => {
      // This will happen when the data service is initialized and can be used
      // if no error is passed.
    });
  },

  /**
   * Initialize the {{capitalcase name}} store state.
   *
   * @return {Object} initial store state.
   */
  getInitialState() {
    return {
      status: 'enabled'
    };
  },

  /**
   * handlers for each action defined in ../actions/index.jsx, for example:
   */
  toggleStatus() {
    this.setState({
      status: this.state.status === 'enabled' ? 'disabled' : 'enabled'
    });
  },

  /**
   * log changes to the store as debug messages.
   * @param  {Object} prevState   previous state.
   */
  storeDidUpdate(prevState) {
    debug('{{pascalcase name}} store changed from %j to %j', prevState, this.state);
  }
});

module.exports = {{pascalcase name}}Store;

@@ -138,70 +138,8 @@
 n');
-%0Aconst %7B DataServiceStore %7D = require('mongodb-data-service');
 %0A%0Aco
@@ -252,17 +252,16 @@
 re.%0A */%0A
-%0A
 const %7B%7B
@@ -702,85 +702,266 @@
 %7B%0A  
-  DataServiceStore.listen((error, dataService) =%3E %7B%0A      //
+%7D,%0A%0A  /**%0A   * This method is called when all packages are activated. Can be%0A   * removed if not needed.%0A   */%0A  onActivated() %7B%0A    // Maybe go to the global.hadronApp.appRegistry and listen to other stores or actions?%0A  %7D,%0A%0A  /**%0A   *
  This 
-will happen
+method is called
  whe
@@ -986,74 +986,221 @@
  is 
+f
 ini
-tialized and can be used%0A      // if no error is passed.%0A    %7D)
+shed connecting.%0A   * If there is an error, the data service is not connected. If not, the%0A   * passed data service is connected.%0A   */%0A  onConnected(error, dataService) %7B%0A    // this.dataService = dataService
 ;%0A  

Update for new lifecycle methods in generated store