seitu 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import type { Readable, Subscribable } from '../core/index';
2
2
  import * as React from 'react';
3
- export type UseSubscriptionSource<S extends Subscribable<any> & Readable<any>> = S | (() => S);
4
3
  export interface UseSubscriptionOptions<S extends Subscribable<any> & Readable<any>, R = S['~']['output']> {
5
4
  selector?: (value: S['~']['output']) => R;
6
5
  deps?: React.DependencyList;
@@ -81,15 +80,15 @@ export interface UseSubscriptionOptions<S extends Subscribable<any> & Readable<a
81
80
  * import { useSubscription } from 'seitu/react'
82
81
  *
83
82
  * export default function Page() {
84
- * const [ref, setRef] = React.useState<HTMLDivElement | null>(null)
85
- * const state = useSubscription(() => scrollState({ element: ref, direction: 'vertical' }), { deps: [ref] })
83
+ * const ref = React.useRef<HTMLDivElement>(null)
84
+ * const state = useSubscription(() => scrollState({ element: () => ref.current, direction: 'vertical' }))
86
85
  *
87
86
  * return (
88
- * <div ref={setRef}>
87
+ * <div ref={ref}>
89
88
  * {String(state.top.value)}
90
89
  * </div>
91
90
  * )
92
91
  * }
93
92
  * ```
94
93
  */
95
- export declare function useSubscription<S extends Subscribable<any> & Readable<any> = Subscribable<any> & Readable<any>, R = S['~']['output']>(source: UseSubscriptionSource<S>, options?: UseSubscriptionOptions<S, R>): R;
94
+ export declare function useSubscription<S extends Subscribable<any> & Readable<any>, R = S['~']['output']>(source: S | (() => S), options?: UseSubscriptionOptions<S, R>): R;