Skip to content

xiaohuoni/snippet

Repository files navigation

Oni JavaScript Snippet

License

Oni JavaScript Snippet for Visual Studio Code

The extension that provide JavaScript and umi snippets for using in Visual Studio Code.

Recommended configurations

To keep snippets to show on the top of suggestions for easy using, use this configuration.

{
	"editor.snippetSuggestions": "top"
}

Snippets

JavaScript Snippets

like: define、forof、forin、foreach、function...

UMI Snippets

[umi-mock] Umi Mock

'/api/hello'(req, res) {
    res.end(`hello ${Math.random()}`);
},

[umi-subscriptions] Umi model subscriptions

setup({ dispatch, history }) {
      return history.listen(({ pathname, query }) => {
        if (pathname === '/') {
          dispatch({ type: 'fetch', payload: query });
        }
      });
},

[umi-effects] Umi model effects

*fetch({ payload: { page = 1 } }, { call, put }) {
      const { data, headers } = yield call(usersService.fetch, { page });
      yield put({
        type: 'save',
        payload: {
          data,
          total: parseInt(headers['x-total-count'], 10),
          page: parseInt(page, 10),
        },
      });
    },

[umi-service] Umi service request

export function create(values) {
  return request('/api/users', {
    method: 'POST',
    body: JSON.stringify(values),
  });
}

About

javascript and umi snippet

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published