From e3316aa8111f006fc131acbfc1ba8f8b97040980 Mon Sep 17 00:00:00 2001 From: eight Date: Sat, 1 Sep 2018 21:29:31 +0800 Subject: [PATCH] Fix: use cacheFirstCall --- edit/linter-help-dialog.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/edit/linter-help-dialog.js b/edit/linter-help-dialog.js index 98c11903..ea9d99f9 100644 --- a/edit/linter-help-dialog.js +++ b/edit/linter-help-dialog.js @@ -1,9 +1,14 @@ -/* global showHelp editorWorker */ +/* global showHelp editorWorker cacheFirstCall */ 'use strict'; function createLinterHelpDialog(getIssues) { let csslintRules; - let preparing; + const prepareCsslintRules = cacheFirstCall(() => + editorWorker.getCsslintRules() + .then(rules => { + csslintRules = rules; + }) + ); return {show}; function show() { @@ -43,14 +48,4 @@ function createLinterHelpDialog(getIssues) { ) ); } - - function prepareCsslintRules() { - if (!preparing) { - preparing = editorWorker.getCsslintRules() - .then(rules => { - csslintRules = rules; - }); - } - return preparing; - } }