How to use the @rematch/core.getState 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 / editor / events / quick-tab-switch.js View on Github external
function quickTabSwitch(type) {
  const state = getState();
  const openedFiles = Array.from(state.project.openedFiles.values());

  if (openedFiles.length === 1) {
    // We can't switch to any other file, there's only one
    return;
  }

  const currentFile = state.session.currentFile.filePath;
  let fileToFallbackTo;
  let currentFileIndex = -1;

  for (let i = 0; i < openedFiles.length; i++) {
    if (openedFiles[i].filePath === currentFile) {
      currentFileIndex = i;
    }
  }
github eveningkid / reacto / src / components / PromptUser / PromptUser.jsx View on Github external
cancelQuestion = () => {
    getState().session.editor.focus();
    this.setState({ ...initialState });
  };
github eveningkid / reacto / src / editor / search / plugins / file-tree.js View on Github external
export default function fileTreePlugin(input) {
  const state = getState();
  const suggestions = [];
  input = input.toLowerCase();
  const openedFiles = Array.from(state.project.openedFiles.values());

  for (const filePath of FileTreeManager.getAllFilePaths()) {
    if (filePath.toLowerCase().includes(input)) {
      const priority = _priorityForFile(filePath, openedFiles);
      const searchSuggestion = new SearchSuggestion({
        type: 'file',
        title: path.basename(filePath),
        description: path.dirname(filePath),
        select: () => {
          const fullFilePath = path.join(state.project.cwd, filePath);
          dispatch.session.openFileAsync(fullFilePath);
        },
        priority,
github eveningkid / reacto / src / tools / task-runners / npm / npm.js View on Github external
get packageManager() {
    return getState().project.packageManager;
  }
github eveningkid / reacto / src / editor / hint / modes / javascript.js View on Github external
getLocalSuggestions = () => {
    const state = getState();
    const currentFilePath = state.session.currentFile.filePath;
    const from = currentFilePath.replace(state.project.cwd, '');
    const filePaths = FileTreeManager.getAllFilePaths().filter(
      filePath => !filePath.includes('node_modules')
    );
    let approvedSuggestions = [];

    for (const to of filePaths) {
      if (from && from !== to) {
        let toFile = path.relative(from, to).substr(2);

        if (toFile.substr(0, 3) !== '/..') {
          toFile = '.' + toFile;
        } else {
          toFile = toFile.substr(1);
        }
github eveningkid / reacto / src / editor / events / switch-package-manager.js View on Github external
function switchPackageManager(type) {
  const currentPackageManager = getState().project.packageManager;
  let packageManager;

  switch (type) {
    default:
    case SwitchPackageManager.NPM:
      if (typeof currentPackageManager !== packageManagers.NpmPackageManager) {
        packageManager = new packageManagers.NpmPackageManager();
      }
      break;

    case SwitchPackageManager.YARN:
      if (typeof currentPackageManager !== packageManagers.YarnPackageManager) {
        packageManager = new packageManagers.YarnPackageManager();
      }
      break;
  }
github eveningkid / reacto / src / tools / formatters / prettier / index.js View on Github external
format = async () => {
    let options = await this.resolveConfig();
    if (!options) options = await this.createConfigurationFile();
    const editor = getState().session.editor;
    const code = editor.getValue();
    return prettier.format(code, options);
  };
github eveningkid / reacto / src / editor / managers / application / application-manager.js View on Github external
static get project() {
    const state = getState();
    return project(state.project, state);
  }