Skip to content

Commit

Permalink
fix(store): integrate into shared (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
2nthony authored Oct 10, 2021
1 parent 9029e20 commit 7975e28
Show file tree
Hide file tree
Showing 34 changed files with 64 additions and 219 deletions.
50 changes: 15 additions & 35 deletions indexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
"display": "SvelteUse",
"description": "Collection of essential Svelte Utilities",
"dir": "packages/core"
},
"store": {
"name": "store",
"display": "Store",
"description": "Enhancement for svelte/store",
"dir": "packages/store"
}
},
"categories": [
"@Store",
"Animation",
"Browser",
"Component",
"Sensors",
"State",
"Store",
"Utilities"
],
"functions": [
{
"name": "readable",
"package": "shared",
"docs": "/shared/readable/",
"category": "Store",
"description": "auto unsubscribe on destory for `readable`"
},
{
"name": "tryOnDestroy",
"package": "shared",
Expand Down Expand Up @@ -82,6 +83,13 @@
"category": "Utilities",
"description": "shorthand for watching value to be truthy"
},
{
"name": "writable",
"package": "shared",
"docs": "/shared/writable/",
"category": "Store",
"description": "auto unsubscribe on destory for `writable`"
},
{
"name": "onClickOutside",
"package": "core",
Expand Down Expand Up @@ -144,34 +152,6 @@
"docs": "/core/useTitle/",
"category": "Browser",
"description": "reactive document title"
},
{
"name": "derived",
"package": "store",
"docs": "/store/derived/",
"category": "@Store",
"description": "origin [derived](https://svelte.dev/docs#derived)"
},
{
"name": "get",
"package": "store",
"docs": "/store/get/",
"category": "@Store",
"description": "origin [get](https://svelte.dev/docs#get)"
},
{
"name": "readable",
"package": "store",
"docs": "/store/readable/",
"category": "@Store",
"description": "auto unsubscribe on destory for `readable`"
},
{
"name": "writable",
"package": "store",
"docs": "/store/writable/",
"category": "@Store",
"description": "auto unsubscribe on destory for `writable`"
}
]
}
6 changes: 0 additions & 6 deletions meta/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ export const packages: PackageManifest[] = [
display: 'SvelteUse',
description: 'Collection of essential Svelte Utilities',
},
{
name: 'store',
display: 'Store',
description: 'Enhancement for svelte/store',
}
]

1 change: 1 addition & 0 deletions packages/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const categoriesOrder = [
'Sensors',
'Animation',
'State',
'Store',
'Component',
'Watch',
'Formatters',
Expand Down
50 changes: 15 additions & 35 deletions packages/core/indexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
"display": "SvelteUse",
"description": "Collection of essential Svelte Utilities",
"dir": "packages/core"
},
"store": {
"name": "store",
"display": "Store",
"description": "Enhancement for svelte/store",
"dir": "packages/store"
}
},
"categories": [
"@Store",
"Animation",
"Browser",
"Component",
"Sensors",
"State",
"Store",
"Utilities"
],
"functions": [
{
"name": "readable",
"package": "shared",
"docs": "/shared/readable/",
"category": "Store",
"description": "auto unsubscribe on destory for `readable`"
},
{
"name": "tryOnDestroy",
"package": "shared",
Expand Down Expand Up @@ -82,6 +83,13 @@
"category": "Utilities",
"description": "shorthand for watching value to be truthy"
},
{
"name": "writable",
"package": "shared",
"docs": "/shared/writable/",
"category": "Store",
"description": "auto unsubscribe on destory for `writable`"
},
{
"name": "onClickOutside",
"package": "core",
Expand Down Expand Up @@ -144,34 +152,6 @@
"docs": "/core/useTitle/",
"category": "Browser",
"description": "reactive document title"
},
{
"name": "derived",
"package": "store",
"docs": "/store/derived/",
"category": "@Store",
"description": "origin [derived](https://svelte.dev/docs#derived)"
},
{
"name": "get",
"package": "store",
"docs": "/store/get/",
"category": "@Store",
"description": "origin [get](https://svelte.dev/docs#get)"
},
{
"name": "readable",
"package": "store",
"docs": "/store/readable/",
"category": "@Store",
"description": "auto unsubscribe on destory for `readable`"
},
{
"name": "writable",
"package": "store",
"docs": "/store/writable/",
"category": "@Store",
"description": "auto unsubscribe on destory for `writable`"
}
]
}
4 changes: 2 additions & 2 deletions packages/core/onClickOutside/demo.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { writable } from '@svelte-use/store'
import { onClickOutside, onClickOutside } from '.'
import { writable } from '@svelte-use/shared'
import { onClickOutside } from '.'
const modal = writable(false)
const modalEl = writable<HTMLDivElement>()
Expand Down
3 changes: 1 addition & 2 deletions packages/core/onClickOutside/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ List for clicks outside of an element. Useful for modal or dropdown.

```js
<script>
import { writable } from '@svelte-use/store'
import { onClickOutside } from '@svelte-use/core'
import { writable, onClickOutside } from '@svelte-use/core'

const target = writable()

Expand Down
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"./*": "./*"
},
"dependencies": {
"@svelte-use/shared": "workspace:*",
"@svelte-use/store": "workspace:*"
"@svelte-use/shared": "workspace:*"
}
}
3 changes: 1 addition & 2 deletions packages/core/useEventListener/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ You can also pass a `writable/readable` as the event target, `useEventListener`

```js
<script>
import { writable } from '@svelte-use/store'
import { useEventListener } from '@svelte-use/core'
import { writable, useEventListener } from '@svelte-use/core'

const el = writable()
useEventListener(el, 'click', (evt) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useMutationObserver/demo.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { writable } from '@svelte-use/store'
import { writable } from '@svelte-use/shared'
import { useMutationObserver } from '.'
const el = writable<HTMLDivElement>()
Expand Down
3 changes: 1 addition & 2 deletions packages/core/useMutationObserver/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Watch for changes being made to the DOM tree. [MutationObserver MDN](https://dev

```js
<script>
import { writable } from '@svelte-use/store'
import { useMutationObserver } from '@svelte-use/core'
import { writable, useMutationObserver } from '@svelte-use/core'

const el = writable()
let messages = []
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useTitle/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isString, MaybeWritable, toWritable } from '@svelte-use/shared'
import { get } from '@svelte-use/store'
import { get } from 'svelte/store'
import { useMutationObserver } from '../useMutationObserver'
import { ConfigurableDocument, defaultDocument } from '../_configurable'

Expand Down
4 changes: 4 additions & 0 deletions packages/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
- [`useSessionStorage`](/core/useSessionStorage/) — reactive [SessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)
- [`useStorage`](/core/useStorage/) — reactive [LocalStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)/[SessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)

### Store
- [`readable`](/shared/readable/) — auto unsubscribe on destory for `readable`
- [`writable`](/shared/writable/) — auto unsubscribe on destory for `writable`

### Utilities
- [`whenever`](/shared/whenever/) — shorthand for watching value to be truthy

Expand Down
2 changes: 1 addition & 1 deletion packages/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Svelte Use is a collection of utility functions.

```bash
npm i @svelte-use/core
# yarn add @svelte-use
# yarn add @svelte-use/core
# pnpm i @svelte-use/core
```

Expand Down
2 changes: 2 additions & 0 deletions packages/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './readable'
export * from './tryOnDestroy'
export * from './tryOnMount'
export * from './useInterval'
Expand All @@ -6,3 +7,4 @@ export * from './useTimeout'
export * from './useTimeoutFn'
export * from './utils'
export * from './whenever'
export * from './writable'
3 changes: 0 additions & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@
"require": "./index.cjs"
},
"./*": "./*"
},
"dependencies": {
"@svelte-use/store": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
category: '@Store'
category: Store
---

# readable
Expand All @@ -10,7 +10,7 @@ Auto unsubscribe on destory for `readable` .

```html
<script>
import { readable } from '@svelte-use/store'
import { readable } from '@svelte-use/core'
const count = readable(0)
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { noop } from '@svelte-use/shared'
import {
Readable,
StartStopNotifier,
} from 'svelte/store'
import { noop } from '../utils'
import { Readable, StartStopNotifier } from 'svelte/store'
import { writable } from '../writable'

export function readable<T>(
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/useInterval/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writable } from '@svelte-use/store'
import { writable } from '../writable'
import { Writable } from 'svelte/store'
import { useIntervalFn } from '../useIntervalFn'
import { Pausable } from '../utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/useIntervalFn/demo.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { writable } from '@svelte-use/store'
import { writable } from '../writable'
import { useIntervalFn } from '.'
const greetings = [
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useIntervalFn/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tryOnDestroy } from '@svelte-use/core'
import { writable } from '@svelte-use/store'
import { tryOnDestroy } from '../tryOnDestroy'
import { writable } from '../writable'
import { Fn, isClient, Pausable } from '../utils'

export interface IntervalFnOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/useTimeout/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Writable } from 'svelte/store'
import { noop, Stopable } from '../utils'
import { TimeoutFnOptions, useTimeoutFn } from '../useTimeoutFn'
import { readable } from '@svelte-use/store'
import { readable } from '../readable'

export interface TimeoutOptions<Controls extends boolean>
extends TimeoutFnOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/useTimeoutFn/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isClient, Stopable } from '../utils'
import { writable } from '@svelte-use/store'
import { writable } from '../writable'
import { tryOnDestroy } from '../tryOnDestroy'

export interface TimeoutFnOptions {
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { get_current_component } from 'svelte/internal'
import { get, readable } from '@svelte-use/store'
import { readable } from '../readable'
import { get } from 'svelte/store'
import { MaybeReadable, MaybeWritable } from './types'
import { isReadable, isWritable } from './is'
import { Readable, writable, Writable } from 'svelte/store'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
category: '@Store'
category: Store
---

# writable
Expand All @@ -10,7 +10,7 @@ Auto unsubscribe on destory for `writable` .

```html
<script>
import { writable } from '@svelte-use/store'
import { writable } from '@svelte-use/core'
const count = writable(0)
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Fn, noop, runAll, tryOnDestroy } from '@svelte-use/shared'
import { Fn, noop, runAll } from '../utils'
import { tryOnDestroy } from '../tryOnDestroy'
import {
writable as _writable,
get,
Expand Down
Loading

0 comments on commit 7975e28

Please sign in to comment.