How to use the @rematch/core.dispatch.session function in @rematch/core

To help you get started, we’ve selected a few @rematch/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eveningkid / reacto / src / store / models / project.js View on Github external
switchProject(cwd, rootState) {
      // If current .cwd
      const currentCwd = rootState.project.cwd;
      if (currentCwd) {
        // Reset both session and project
        dispatch.session.resetSession();
        dispatch.project.resetProject();
      }

      // Change local .cwd
      this.updateCwd(cwd);

      // Add or update history's recent project
      dispatch.history.addOrUpdateRecentProject(cwd);
    },
  },
github eveningkid / reacto / src / editor / events / quick-file-switch.js View on Github external
const openedFiles = Array.from(state.project.openedFiles.values());
  const currentFile = state.session.currentFile.filePath;

  if (openedFiles.length <= 1) return;

  let fileToOpen;
  if (number === 9) {
    // Opening the last file in the list
    fileToOpen = openedFiles.slice(-1)[0];
  } else if (openedFiles[number - 1]) {
    // Number goes from 1~8, array from 0~7
    fileToOpen = openedFiles[number - 1];
  }

  if (!fileToOpen || currentFile === fileToOpen) return;
  dispatch.session.openFileAsync(fileToOpen.filePath);
}
github eveningkid / reacto / src / editor / events / save-file.js View on Github external
.then(() => {
          // Let our store know that there is no more unsaved changed
          dispatch.session.savedFile();
          resolve();
        })
        .catch(error => reject(error));
github eveningkid / reacto / src / editor / events / new-file.js View on Github external
newFilePath => {
      const fullNewFilePath = path.join(state.project.cwd, newFilePath);
      console.log(fullNewFilePath);
      dispatch.session.createFileAsync(fullNewFilePath);
    }
  );
github eveningkid / reacto / src / editor / events / quick-tab-switch.js View on Github external
if (nextIndex > openedFilesLength) {
        nextFile = openedFiles[0];
      } else {
        nextFile = openedFiles[currentFileIndex + 1];
      }

      if (nextFile) {
        fileToFallbackTo = nextFile.filePath;
      }

      break;
  }

  if (fileToFallbackTo) {
    dispatch.session.openFileAsync(fileToFallbackTo);
  }
}
github eveningkid / reacto / src / components / TodoList / TodoList.jsx View on Github external
          onClick={() => dispatch.session.openFileAsync(file.filePath)}
        >
github eveningkid / reacto / src / menus / file-tree-entry-menu.js View on Github external
dialog.showMessageBox(options, async response => {
          if (response === 1) {
            await dispatch.session.closeFileAsync(filePath);

            if (!shell.moveItemToTrash(filePath)) {
              log.info("Couldn't send", filePath, 'to trash');
            }
          }
        });
      },
github eveningkid / reacto / src / editor / search / plugins / file-tree.js View on Github external
select: () => {
          const fullFilePath = path.join(state.project.cwd, filePath);
          dispatch.session.openFileAsync(fullFilePath);
        },
        priority,
github eveningkid / reacto / src / editor / managers / formatter-manager.js View on Github external
static format = async () => {
    try {
      const generatedCode = await FormatterManager.formatter.format();
      dispatch.session.updateGeneratedCode({ generatedCode });
    } catch (error) {
      log.warn('[Error] Formatter: Could not parse code.');
    }
  };
github eveningkid / reacto / src / menus / file-tree-entry-menu.js View on Github external
newFilePath => {
            dispatch.session.createFileAsync(newFilePath);
          }
        );