From e06f8a72abb24b050a9ad3bc08bf2487248efdec Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 28 Oct 2024 16:44:16 -0400 Subject: [PATCH] fix(curriculum): update Redux store listener to not allow direct calls (#56625) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lasse Jørgensen <28780271+lasjorg@users.noreply.github.com> --- .../redux/register-a-store-listener.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/curriculum/challenges/english/03-front-end-development-libraries/redux/register-a-store-listener.md b/curriculum/challenges/english/03-front-end-development-libraries/redux/register-a-store-listener.md index d3d43ced41e..50b80724e69 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/redux/register-a-store-listener.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/redux/register-a-store-listener.md @@ -32,19 +32,25 @@ assert( There should be a listener function subscribed to the store using `store.subscribe`. ```js -(getUserInput) => assert(getUserInput('index').match(/store\s*\.\s*subscribe\(/gm)); +assert.match(code, /store\s*\.\s*subscribe\(/gm); ``` The `store.subscribe` should receive a function. ```js -(getUserInput) => assert(getUserInput('index').match(/(\s*function\s*)|(\s*\(\s*\)\s*=>)/gm)) +assert.match(code, /(\s*function\s*)|(\s*\(\s*\)\s*=>)/gm); +``` + +The function passed to `store.subscribe` should not be called. + +```js +assert.notMatch(code, /store\.subscribe\(.+\(\)\)/); ``` The callback to `store.subscribe` should also increment the global `count` variable as the store is updated. ```js -assert(store.getState() === count); +assert.strictEqual(store.getState(), count); ``` # --seed--