Sha256: 3547b892b0237b85a25231a4d26e337042a4a3648899aaaa9d6176353797c12a
Contents?: true
Size: 793 Bytes
Versions: 14
Compression:
Stored size: 793 Bytes
Contents
require 'volt/reactive/hash_dependency' class ReactiveHash def initialize(values={}) @hash = values @deps = HashDependency.new @all_deps = Dependency.new end def ==(val) @all_deps.depend @hash == val end # TODO: We should finish off this class for reactivity def method_missing(method_name, *args, &block) @all_deps.depend return @hash.send(method_name, *args, &block) end def [](key) @deps.depend(key) return @hash[key] end def []=(key, value) @deps.changed!(key) @all_deps.changed! @hash[key] = value end def delete(key) @deps.delete(key) @hash.delete(key) end def clear @hash.each_pair do |key,_| delete(key) end end def inspect "#<ReactiveHash #{@hash.inspect}>" end end
Version data entries
14 entries across 14 versions & 1 rubygems