https://github.com/douganderson444/hyper-svelte-component
A Svelte component of Hyperdrive using the dat-sdk
https://github.com/douganderson444/hyper-svelte-component
Last synced: 3 months ago
JSON representation
A Svelte component of Hyperdrive using the dat-sdk
- Host: GitHub
- URL: https://github.com/douganderson444/hyper-svelte-component
- Owner: DougAnderson444
- Created: 2020-09-05T00:13:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-14T22:08:00.000Z (over 4 years ago)
- Last Synced: 2024-03-25T10:45:34.939Z (about 1 year ago)
- Language: JavaScript
- Size: 468 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hyper-Svelte-Component
A [Svelte](https://svelte.dev) <[Component](https://github.com/sveltejs/component-template) /> for managing [Hyperdrives](https://github.com/hypercore-protocol/hyperdrive) using the [dat-sdk](https://github.com/datproject/sdk).
You can also bind Hypercores to the component.
## Why
When using the dat SDK you've got to [close](https://github.com/datproject/sdk#await-close) it when you're done with the SDK, and keeping track of the close is a bit of a pain. So I bundled the creation of the hyperdrive and the close function into a [Svelte](https://svelte.dev) component. Whenever the component is `destroyed` or the `window.unloads` the `await close()` function for the SDK's Hyperdrive will be closed. So you don't have to worry about it.
## Usage
All you do is pass in an instance of the `SDK` and bind the componet's output what you want `Hyperdrive` to be called (if you wan to rename it, or have multiple SDK instances, to simulate many peers on one device).
```js
import HyperComponent from "hyper-svelte-component";const original = makeDrives("original-drive-name")
await original.ready()
// ... more Hyperdrive moves afterward// To simulate two peers in the same browser, you'll need another SDK instance
const copy = makeDriveCopies(original.key)```
---
## See also
[Svelte](https://svelte.dev)
[dat-sdk](https://github.com/datproject/sdk)
[Hyperdrives](https://github.com/hypercore-protocol/hyperdrive)