eina: use a timer instead of another future for our first example
This commit is contained in:
parent
6a31dd60db
commit
348ea10272
|
@ -37,15 +37,15 @@ _value_print(void *data EINA_UNUSED, const Eina_Value value)
|
|||
/*
|
||||
* This method will resolve the passed promise with a string value
|
||||
*/
|
||||
static Eina_Value
|
||||
_delayed_value_resolve(void *data, const Eina_Value value EINA_UNUSED)
|
||||
static void
|
||||
_delayed_value_resolve(void *data, const Efl_Event *event)
|
||||
{
|
||||
Eina_Promise *promise;
|
||||
|
||||
promise = (Eina_Promise *)data;
|
||||
eina_promise_resolve(promise, eina_value_string_init("Delayed Value :)"));
|
||||
|
||||
return EINA_VALUE_EMPTY;
|
||||
efl_del(event->object);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -66,8 +66,10 @@ _simple_future()
|
|||
eina_future_then_easy(eina_future_new(promise), .success = _value_print);
|
||||
|
||||
// This future is basically a timer - wait 100ms and then resolve the promise above
|
||||
eina_future_then_easy(efl_loop_timeout(efl_loop_main_get(EFL_LOOP_CLASS), 0.1),
|
||||
.success = _delayed_value_resolve, .data = promise);
|
||||
efl_add(EFL_LOOP_TIMER_CLASS, loop,
|
||||
efl_loop_timer_interval_set(efl_added, 0.1),
|
||||
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
|
||||
_delayed_value_resolve, promise));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue