Only send changes back to client
This commit is contained in:
@@ -11,10 +11,20 @@ feature
|
||||
|
||||
control_name: STRING
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make (n: STRING)
|
||||
do
|
||||
control_name := n
|
||||
create state_changes.make
|
||||
ensure
|
||||
attached state_changes
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Select state stored with `control_name` as key
|
||||
-- Select state stored with `control_name` as key
|
||||
do
|
||||
if attached {JSON_OBJECT} new_states.item (create {JSON_STRING}.make_json (control_name)) as new_state_obj then
|
||||
set_state (new_state_obj)
|
||||
@@ -22,32 +32,42 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Before we process the callback. We restore the state of control.
|
||||
-- Before we process the callback. We restore the state of control.
|
||||
deferred
|
||||
end
|
||||
|
||||
read_state (states: JSON_OBJECT)
|
||||
-- Add a new entry in the `states` JSON object with the `control_name` as key and the `state` as value
|
||||
-- Add a new entry in the `states` JSON object with the `control_name` as key and the `state` as value
|
||||
do
|
||||
states.put (state, create {JSON_STRING}.make_json (control_name))
|
||||
end
|
||||
|
||||
read_state_changes (states: JSON_OBJECT)
|
||||
-- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value
|
||||
do
|
||||
if state_changes.count > 0 then
|
||||
states.put (state_changes, create {JSON_STRING}.make_json (control_name))
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Returns the current state of the Control as JSON. This state will be transfered to the client.
|
||||
-- Returns the current state of the Control as JSON. This state will be transfered to the client.
|
||||
deferred
|
||||
end
|
||||
|
||||
state_changes: JSON_OBJECT
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
handle_callback (cname: STRING; event: STRING)
|
||||
-- Method called if any callback recived. In this method you can route the callback to the event handler
|
||||
-- Method called if any callback recived. In this method you can route the callback to the event handler
|
||||
deferred
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
render: STRING
|
||||
-- Return html representaion of control
|
||||
-- Return html representaion of control
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user