ripple 0.2.97 → 0.2.98
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.
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { DERIVED, TRACKED, UNINITIALIZED } from './internal/client/constants.js'
|
|
|
4
4
|
import { is_tracked_object } from './internal/client/utils.js';
|
|
5
5
|
import { active_component } from './internal/server/index.js';
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { Context } from './internal/server/context.js';
|
|
8
8
|
|
|
9
9
|
export function effect() {
|
|
10
10
|
// NO-OP
|
|
@@ -44,4 +44,3 @@ export function track(v, get, set) {
|
|
|
44
44
|
v,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
|
|
@@ -58,12 +58,3 @@ export class Context {
|
|
|
58
58
|
current_context.set(context, value);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @template T
|
|
64
|
-
* @param {T} initial_value
|
|
65
|
-
* @returns {Context<T>}
|
|
66
|
-
*/
|
|
67
|
-
export function create_context(initial_value) {
|
|
68
|
-
return new Context(initial_value);
|
|
69
|
-
}
|
|
@@ -58,12 +58,3 @@ export class Context {
|
|
|
58
58
|
current_context.set(context, value);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @template T
|
|
64
|
-
* @param {T} initial_value
|
|
65
|
-
* @returns {Context<T>}
|
|
66
|
-
*/
|
|
67
|
-
export function create_context(initial_value) {
|
|
68
|
-
return new Context(initial_value);
|
|
69
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { mount,
|
|
2
|
+
import { mount, Context, flushSync, track } from 'ripple';
|
|
3
3
|
|
|
4
4
|
describe('context', () => {
|
|
5
5
|
let container;
|
|
@@ -20,7 +20,7 @@ describe('context', () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('creates a reactive ref with initial value', () => {
|
|
23
|
-
const MyContext =
|
|
23
|
+
const MyContext = new Context(null);
|
|
24
24
|
|
|
25
25
|
component Child() {
|
|
26
26
|
const value = MyContext.get();
|
|
@@ -42,8 +42,8 @@ describe('context', () => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it('handles context captured inside a computed tracked', () => {
|
|
45
|
-
|
|
46
|
-
const MyContext =
|
|
45
|
+
|
|
46
|
+
const MyContext = new Context(null)
|
|
47
47
|
|
|
48
48
|
const doubleContext = () => {
|
|
49
49
|
const value = MyContext.get()
|
|
@@ -52,7 +52,7 @@ describe('context', () => {
|
|
|
52
52
|
|
|
53
53
|
component App() {
|
|
54
54
|
MyContext.set(4)
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
<h3>{MyContext.get()}</h3>
|
|
57
57
|
|
|
58
58
|
<h4>{'2x:'} {doubleContext()}</h4>
|
package/types/index.d.ts
CHANGED
|
@@ -24,12 +24,12 @@ export interface TrackedArray<T> extends Array<T> { }
|
|
|
24
24
|
|
|
25
25
|
export declare const TrackedArray: TrackedArrayConstructor;
|
|
26
26
|
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
export declare class Context<T> {
|
|
28
|
+
constructor(initial_value: T);
|
|
29
|
+
get(): T;
|
|
30
|
+
set(value: T): void;
|
|
31
|
+
#private;
|
|
32
|
+
}
|
|
33
33
|
|
|
34
34
|
export declare class TrackedSet<T> extends Set<T> {
|
|
35
35
|
isDisjointFrom(other: TrackedSet<T> | Set<T>): boolean;
|