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
fb7cc16c
Commit
fb7cc16c
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-state: transform index, behavior event helper
parent
f2594993
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-state/transformer.ts
+16
-0
16 additions, 0 deletions
src/mol-state/transformer.ts
src/mol-util/rx-event-helper.ts
+1
-0
1 addition, 0 deletions
src/mol-util/rx-event-helper.ts
with
17 additions
and
0 deletions
src/mol-state/transformer.ts
+
16
−
0
View file @
fb7cc16c
...
...
@@ -81,6 +81,17 @@ export namespace Transformer {
}
const
registry
=
new
Map
<
Id
,
Transformer
<
any
,
any
>>
();
const
fromTypeIndex
:
Map
<
StateObject
.
Type
,
Transformer
[]
>
=
new
Map
();
function
_index
(
tr
:
Transformer
)
{
for
(
const
t
of
tr
.
definition
.
from
)
{
if
(
fromTypeIndex
.
has
(
t
.
type
))
{
fromTypeIndex
.
get
(
t
.
type
)
!
.
push
(
tr
);
}
else
{
fromTypeIndex
.
set
(
t
.
type
,
[
tr
]);
}
}
}
export
function
get
(
id
:
string
):
Transformer
{
const
t
=
registry
.
get
(
id
as
Id
);
...
...
@@ -90,6 +101,10 @@ export namespace Transformer {
return
t
;
}
export
function
fromType
(
type
:
StateObject
.
Type
):
ReadonlyArray
<
Transformer
>
{
return
fromTypeIndex
.
get
(
type
)
||
[];
}
export
function
create
<
A
extends
StateObject
,
B
extends
StateObject
,
P
>
(
namespace
:
string
,
definition
:
Definition
<
A
,
B
,
P
>
)
{
const
{
name
}
=
definition
;
const
id
=
`
${
namespace
}
.
${
name
}
`
as
Id
;
...
...
@@ -105,6 +120,7 @@ export namespace Transformer {
definition
};
registry
.
set
(
id
,
t
);
_index
(
t
);
return
t
;
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/rx-event-helper.ts
+
1
−
0
View file @
fb7cc16c
...
...
@@ -19,6 +19,7 @@ namespace RxEventHelper {
const
helper
=
new
_RxEventHelper
();
const
ret
:
RxEventHelper
=
(
<
T
>
()
=>
helper
.
create
<
T
>
())
as
RxEventHelper
;
ret
.
dispose
=
()
=>
helper
.
dispose
();
ret
.
behavior
=
(
v
)
=>
helper
.
behavior
(
v
);
return
ret
;
}
}
...
...
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