From 36733c7fa6de655cc31449eb3610ec9d907448c3 Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Sun, 29 Apr 2018 22:36:01 -0500 Subject: [PATCH] fix readme type --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index db56626..30e85ad 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ const fetchUser = id => fetch(`/users/${id}`).then(res => res.json()) const UserFetcher = new PromiseMiddleware(fetchUser) // tell the cache how to get the entity's id based on the arguments the fetch request is given -const idGetter = (...args) => args[0] +const idGetter = id => id // cache requests using a normalized state tree cache(idGetter)(UserFetcher) @@ -50,10 +50,10 @@ import UserFetcher from 'fetchers/User' // args will be an array of the arguments provided when we call "request" and res will be whatever the promise // originally given to the PromiseMiddleware resolved with // returns a callback to unsubscribe the middleware -const unsubscribe = UserFetcher.onSuccess(({ res, args }) => onUserFetchSuccess(res, idGetter(...args))) +const unsubscribe = UserFetcher.onSuccess(onUserFetchSuccess) -function onUserFetchSuccess({ res }) { - console.log(`Got the user with the id ${id}!`, res) +function onUserFetchSuccess({ res, args }) { + console.log(`Got the user with the id ${idGetter(...args)}!`, res) } UserFetcher.request(1)