Created
March 25, 2023 23:02
-
-
Save dmoss18/0958cf7f7829e3a779448401998470d5 to your computer and use it in GitHub Desktop.
This file contains 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
class TastytradeContext { | |
public tastytradeApi: TastytradeApi | |
public customer: Customer | null = null | |
public account: Account | null = null | |
public accountBalance: AccountBalance | null = null | |
constructor(baseUrl: string) { | |
this.tastytradeApi = new TastytradeApi(baseUrl) | |
} | |
} | |
const AppContext = createContext(new TastytradeContext('https://api.cert.tastyworks.com')) | |
function MyPage() { | |
const appContext = useAppContext() | |
const handleLogin = (username: string, password: string) => { | |
await appContext.tastytradeApi.sessionService.login(username, password) | |
// TODO: Navigate to a page | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment