RangerMauve / hyper-sdk

Make your own hyper apps!
https://www.youtube.com/watch?v=HyHk4aImd_I&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=20
MIT License
291 stars 46 forks source link

Browser Bundle README Issue #89

Closed r-token closed 3 years ago

r-token commented 3 years ago

Following the Building a bundle for Browsers section of the README, I wasn't able to get things to work until I changed:

const SDK = window.hyperSDK to const SDK = await window.hyperSDK() within an async function.

Using the original way, I was getting an error in the console saying TypeError: this.Hypercore is not a function

Is this expected? If you'd like, I can submit a PR to update the README with an extra line of info showing that one may need to try it the await way.

RangerMauve commented 3 years ago

Thank you for pointing this out, I think this might be an issue with the wording. window.hyperSDK is the constructor for the SDK and not an instance of the SDK.

When you call await SDK(options) you're creating an instance which you can then call Hyperdrive and Hypercore on.

Note the API example which has const sdk = await SDK() here: https://github.com/datproject/sdk#apiexamples

A PR with better wording for that section would be appreicated.