Created
June 12, 2020 16:14
-
-
Save ross-u/12400a6b2e36edc2ec1b8cecc5753ddf to your computer and use it in GitHub Desktop.
Subscription function test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mockFetch(str) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve({ name: "Uros", job: "SE" }), 3000); | |
}); | |
} | |
function subscribeOnAuth(cb) { | |
const unsub = () => { | |
console.log("unsubed"); | |
cb = () => console.log("nothing");; | |
}; | |
mockFetch("https://google.com") | |
.then(data => cb(data)) | |
.catch(err => err); | |
return unsub; | |
} | |
const unsub = subscribeOnAuth(auth => { | |
console.log("unsubscribeOnAuth", auth); | |
}); | |
//unsub() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment