@@ -2,51 +2,47 @@ defmodule ElixirScript.Agent do
22 @ moduledoc false
33
44 def start ( fun , options \\ [ ] ) do
5- pid = JS . new JS.Bootstrap.Core.PID , [ ]
6-
75 name = if Keyword . has_key? ( options , :name ) do
86 Keyword . get ( options , :name )
97 else
108 nil
119 end
1210
13- ElixirScript. Store. create ( pid , fun . ( ) , name )
11+ pid = Bootstrap.Core. Store. create ( fun . ( ) , name )
1412 { :ok , pid }
1513 end
1614
1715 def start_link ( fun , options \\ [ ] ) do
18- pid = JS . new JS.Bootstrap.Core.PID , [ ]
19-
2016 name = if Keyword . has_key? ( options , :name ) do
2117 Keyword . get ( options , :name )
2218 else
2319 nil
2420 end
2521
26- ElixirScript. Store. create ( pid , fun . ( ) , name )
22+ pid = Bootstrap.Core. Store. create ( fun . ( ) , name )
2723 { :ok , pid }
2824 end
2925
3026 def stop ( agent ) do
31- ElixirScript .Store. remove ( agent )
27+ Bootstrap.Core .Store. remove ( agent )
3228 :ok
3329 end
3430
3531 def update ( agent , fun ) do
36- current_state = ElixirScript .Store. read ( agent )
37- ElixirScript .Store. update ( agent , fun . ( current_state ) )
32+ current_state = Bootstrap.Core .Store. read ( agent )
33+ Bootstrap.Core .Store. update ( agent , fun . ( current_state ) )
3834 :ok
3935 end
4036
4137 def get ( agent , fun ) do
42- current_state = ElixirScript .Store. read ( agent )
38+ current_state = Bootstrap.Core .Store. read ( agent )
4339 fun . ( current_state )
4440 end
4541
4642 def get_and_update ( agent , fun ) do
47- current_state = ElixirScript .Store. read ( agent )
43+ current_state = Bootstrap.Core .Store. read ( agent )
4844 { val , new_state } = fun . ( current_state )
49- ElixirScript .Store. update ( agent , new_state )
45+ Bootstrap.Core .Store. update ( agent , new_state )
5046 val
5147 end
5248
0 commit comments