Skip to content

Instantly share code, notes, and snippets.

@dmoss18
Created March 25, 2023 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmoss18/0958cf7f7829e3a779448401998470d5 to your computer and use it in GitHub Desktop.
Save dmoss18/0958cf7f7829e3a779448401998470d5 to your computer and use it in GitHub Desktop.
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