Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
ab183d9c
Commit
ab183d9c
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-state: wip
parent
ea635a69
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-state/context.ts
+3
-3
3 additions, 3 deletions
src/mol-state/context.ts
src/mol-state/object.ts
+6
-5
6 additions, 5 deletions
src/mol-state/object.ts
src/mol-state/state.ts
+9
-9
9 additions, 9 deletions
src/mol-state/state.ts
with
18 additions
and
17 deletions
src/mol-state/context.ts
+
3
−
3
View file @
ab183d9c
...
...
@@ -34,15 +34,15 @@ class StateContext {
};
readonly
globalContext
:
unknown
;
readonly
default
ObjectProps
:
unknown
;
readonly
default
CellState
:
unknown
;
dispose
()
{
this
.
ev
.
dispose
();
}
constructor
(
params
:
{
globalContext
:
unknown
,
default
ObjectProps
:
unknown
,
rootRef
:
Transform
.
Ref
})
{
constructor
(
params
:
{
globalContext
:
unknown
,
default
CellState
:
unknown
,
rootRef
:
Transform
.
Ref
})
{
this
.
globalContext
=
params
.
globalContext
;
this
.
default
ObjectProps
=
params
.
default
ObjectProps
;
this
.
default
CellState
=
params
.
default
CellState
;
this
.
behaviors
.
currentObject
.
next
({
ref
:
params
.
rootRef
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-state/object.ts
+
6
−
5
View file @
ab183d9c
...
...
@@ -37,18 +37,19 @@ namespace StateObject {
interface
StateObjectCell
{
ref
:
Transform
.
Ref
,
props
:
unknown
,
version
:
string
status
:
StateObjectCell
.
Status
,
state
:
unknown
,
errorText
?:
string
,
obj
?:
StateObject
,
version
:
string
obj
?:
StateObject
}
namespace
StateObjectCell
{
export
type
Status
=
'
ok
'
|
'
error
'
|
'
pending
'
|
'
processing
'
export
interface
Props
{
export
interface
State
{
isVisible
:
boolean
,
isHidden
:
boolean
,
isBound
:
boolean
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-state/state.ts
+
9
−
9
View file @
ab183d9c
...
...
@@ -33,7 +33,7 @@ class State {
const
key
=
keys
.
next
();
if
(
key
.
done
)
break
;
const
o
=
this
.
cells
.
get
(
key
.
value
)
!
;
props
[
key
.
value
]
=
{
...
o
.
props
};
props
[
key
.
value
]
=
{
...
o
.
state
};
}
return
{
tree
:
StateTree
.
toJSON
(
this
.
_tree
),
...
...
@@ -79,22 +79,22 @@ class State {
});
}
constructor
(
rootObject
:
StateObject
,
params
?:
{
globalContext
?:
unknown
,
default
ObjectProps
?:
unknown
})
{
constructor
(
rootObject
:
StateObject
,
params
?:
{
globalContext
?:
unknown
,
default
CellState
?:
unknown
})
{
const
tree
=
this
.
_tree
;
const
root
=
tree
.
getValue
(
tree
.
rootRef
)
!
;
const
default
ObjectProps
=
(
params
&&
params
.
default
ObjectProps
)
||
{
}
const
default
CellState
=
(
params
&&
params
.
default
CellState
)
||
{
}
this
.
cells
.
set
(
tree
.
rootRef
,
{
ref
:
tree
.
rootRef
,
obj
:
rootObject
,
status
:
'
ok
'
,
version
:
root
.
version
,
props
:
{
...
default
ObjectProps
}
state
:
{
...
default
CellState
}
});
this
.
context
=
new
StateContext
({
globalContext
:
params
&&
params
.
globalContext
,
default
ObjectProps
,
default
CellState
,
rootRef
:
tree
.
rootRef
});
}
...
...
@@ -183,7 +183,7 @@ namespace State {
obj
.
status
=
status
;
obj
.
errorText
=
errorText
;
}
else
{
const
obj
:
StateObjectCell
=
{
ref
,
status
,
version
:
UUID
.
create
(),
errorText
,
props
:
{
...
ctx
.
stateCtx
.
default
ObjectProps
}
};
const
obj
:
StateObjectCell
=
{
ref
,
status
,
version
:
UUID
.
create
(),
errorText
,
state
:
{
...
ctx
.
stateCtx
.
default
CellState
}
};
ctx
.
cells
.
set
(
ref
,
obj
);
changed
=
true
;
}
...
...
@@ -268,7 +268,7 @@ namespace State {
obj
,
status
:
'
ok
'
,
version
:
transform
.
version
,
props
:
{
...
ctx
.
stateCtx
.
default
ObjectProps
,
...
transform
.
defaultProps
}
state
:
{
...
ctx
.
stateCtx
.
default
CellState
,
...
transform
.
defaultProps
}
});
return
{
action
:
'
created
'
,
obj
};
}
else
{
...
...
@@ -288,13 +288,13 @@ namespace State {
obj
,
status
:
'
ok
'
,
version
:
transform
.
version
,
props
:
{
...
ctx
.
stateCtx
.
default
ObjectProps
,
...
current
.
props
,
...
transform
.
defaultProps
}
state
:
{
...
ctx
.
stateCtx
.
default
CellState
,
...
current
.
state
,
...
transform
.
defaultProps
}
});
return
{
action
:
'
replaced
'
,
oldObj
:
current
.
obj
!
,
newObj
:
obj
};
}
case
Transformer
.
UpdateResult
.
Updated
:
current
.
version
=
transform
.
version
;
current
.
props
=
{
...
ctx
.
stateCtx
.
default
ObjectProps
,
...
current
.
props
,
...
transform
.
defaultProps
};
current
.
state
=
{
...
ctx
.
stateCtx
.
default
CellState
,
...
current
.
state
,
...
transform
.
defaultProps
};
return
{
action
:
'
updated
'
,
obj
:
current
.
obj
};
default
:
// TODO check if props need to be updated
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment