-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathContext.njs
More file actions
69 lines (55 loc) · 2.18 KB
/
Context.njs
File metadata and controls
69 lines (55 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import Nullstack from 'nullstack'
class Context extends Nullstack {
frameworkInitial = '';
static async setContextKey(context) {
context.framework = 'Nullstack'
}
static async getContextKey({ framework }) {
return framework
}
static staticFunction(context) {
return context === undefined
}
static _staticUnderlineFunction(context) {
return context === undefined
}
static async _staticAsyncUnderlineFunction(context) {
return context === undefined
}
static async invokeStaticAsyncUnderlineFunction() {
return this._staticAsyncUnderlineFunction()
}
async initiate(context) {
await this.setContextKey()
context.framework = await this.getContextKey()
this.setFrameworkInitial()
this.staticFunctionHasNoContext = await Context.staticFunction()
this.staticUnderlineFunctionHasNoContext = await Context._staticUnderlineFunction()
this.staticAsyncUnderlineFunctionHasNoContext = await Context.invokeStaticAsyncUnderlineFunction()
}
async hydrate() {
this.hydratedStaticFunctionHasNoContext = await Context.staticFunction()
this.hydratedStaticUnderlineFunctionHasNoContext = await Context._staticUnderlineFunction()
this.hydratedStaticAsyncUnderlineFunctionHasNoContext = await Context.invokeStaticAsyncUnderlineFunction()
}
setFrameworkInitial({ framework }) {
this.frameworkInitial = framework[0]
}
render({ framework }) {
return (
<div
data-framework={framework}
data-framework-initial={this.frameworkInitial}
data-static-function-has-no-context={this.staticFunctionHasNoContext}
data-static-underline-function-has-no-context={this.staticUnderlineFunctionHasNoContext}
data-static-async-underline-function-has-no-context={this.staticAsyncUnderlineFunctionHasNoContext}
data-hydrated-static-function-has-no-context={this.hydratedStaticFunctionHasNoContext}
data-hydrated-static-underline-function-has-no-context={this.hydratedStaticUnderlineFunctionHasNoContext}
data-hydrated-static-async-underline-function-has-no-context={
this.hydratedStaticAsyncUnderlineFunctionHasNoContext
}
/>
)
}
}
export default Context