hyalite 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/client/hyalite/component.rb +49 -3
- data/lib/hyalite/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ea1c7240e460e33ee5ebfc1e434cd7493198c45
|
4
|
+
data.tar.gz: c5f2098f1cfad4a794930c88f3adca4b0e6d15fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cbdd7ea485e11cd21a38a898b3f6287e122d5e55664ccc5843672a8e7c7c897b7842e96991f673b20ce334a37f15f3106d427e1d1fa311ed34dfd677711acc8
|
7
|
+
data.tar.gz: b62902c084737bc896fc51690a8ee60ca7b819b6946741643e255ed2abf37733f1fd7fe078600d64bb5f82bca663ab719a254e3751bbf425cc34eece7b7f28e3
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Hyalite
|
2
2
|
====
|
3
3
|
|
4
|
+
[](https://travis-ci.org/youchan/hyalite)
|
5
|
+
[](https://gitter.im/youchan/hyalite?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
6
|
+
|
7
|
+
|
4
8
|
This is ruby virtual DOM implementation using opal. It is inspired by react.js.
|
5
9
|
|
6
10
|
Example
|
data/client/hyalite/component.rb
CHANGED
@@ -3,18 +3,36 @@ require 'hyalite/short_hand'
|
|
3
3
|
module Hyalite
|
4
4
|
module Component
|
5
5
|
|
6
|
-
attr_accessor :props, :
|
6
|
+
attr_accessor :props, :context, :refs
|
7
7
|
|
8
8
|
def init_component(props, context, updator)
|
9
9
|
@props = props
|
10
10
|
@context = context
|
11
11
|
@updator = updator
|
12
|
-
@state = initial_state
|
12
|
+
@state = State.new(self, updator, initial_state)
|
13
13
|
@refs = nil
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.included(clazz)
|
17
|
+
clazz.instance_eval do
|
18
|
+
define_singleton_method(:state) do |key, initial_value|
|
19
|
+
(@initial_state ||= {})[key] = initial_value
|
20
|
+
end
|
21
|
+
|
22
|
+
define_singleton_method(:initial_state) { @initial_state || {} }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
def initial_state
|
17
|
-
|
27
|
+
self.class.initial_state
|
28
|
+
end
|
29
|
+
|
30
|
+
def state
|
31
|
+
@state.to_h
|
32
|
+
end
|
33
|
+
|
34
|
+
def state=(state)
|
35
|
+
@state.set(state)
|
18
36
|
end
|
19
37
|
|
20
38
|
def context_types
|
@@ -63,6 +81,34 @@ module Hyalite
|
|
63
81
|
|
64
82
|
def render
|
65
83
|
end
|
84
|
+
|
85
|
+
class State
|
86
|
+
def initialize(component, updator, initial_state)
|
87
|
+
@component = component
|
88
|
+
@updator = updator
|
89
|
+
@state = initial_state.clone
|
90
|
+
initial_state.each do |key, value|
|
91
|
+
define_singleton_method(key) do
|
92
|
+
@state[key]
|
93
|
+
end
|
94
|
+
define_singleton_method(key + '=') do |value|
|
95
|
+
@updator.enqueue_set_state(@component, key => value)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def [](key)
|
101
|
+
@state[key]
|
102
|
+
end
|
103
|
+
|
104
|
+
def set(state)
|
105
|
+
@state = state.clone
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_h
|
109
|
+
@state
|
110
|
+
end
|
111
|
+
end
|
66
112
|
end
|
67
113
|
|
68
114
|
class EmptyComponent
|
data/lib/hyalite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyalite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youchan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".gitignore"
|
76
77
|
- ".travis.yml"
|
77
78
|
- Gemfile
|
78
79
|
- Gemfile.lock
|