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
{ | |
"parser": "@typescript-eslint/parser", | |
"parserOptions": { | |
"ecmaVersion": 2018, | |
"sourceType": "module" | |
}, | |
"settings": { | |
"import/resolver": { | |
"typescript": {} // this loads <rootdir>/tsconfig.json to eslint | |
} |
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
const pubSub = (() => { | |
const topicSubscriberMap = new Map(); | |
const throwError = (topic) => { | |
throw new Error(` | |
No ${topic} named topic found in the registry. | |
Available topics:- ${JSON.stringify(getAllTopic())} | |
`); | |
}; | |
const getAllTopic = () => Array.from(topicSubscriberMap.keys()); |
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
import React from "react"; | |
import { useUser, UserProvider } from "./user-context"; | |
const Address = () => { | |
const { | |
state: { | |
user: { address } | |
} | |
} = useUser(); | |
return ( |
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
const makeObservable = (fn) => { | |
const observers = new Map(); | |
const register = (observer) => observers.set(observer, observer); | |
const deRegister = (observer) => observers.delete(observer) | |
const notify = (value) => observers.forEach(observer => observer && observer(value)); | |
fn(notify); | |
return { register, deRegister }; | |
} |