rsc_update_done

An updated resource has just been persisted. Observe this notification to execute follow-up actions for a resource update.

Type:
notify
Return:
return value is ignored
#rsc_update_done{} properties:
  • action: insert|update|delete
  • id: m_rsc:resource_id()
  • pre_is_a: list
  • post_is_a: list
  • pre_props: m_rsc:props()
  • post_props: m_rsc:props()
pre_is_a
List of resource categories before the update.
post_is_a
List of resource categories after the update.
pre_props
Map of properties before the update.
post_props
Map of properties after the update.

Example

Add some default edges when a resource is created:

observe_rsc_update_done(#rsc_update_done{action = insert, id = Id, post_is_a = PostIsA, post_props = Props}, Context) ->
    case lists:member(activity, PostIsA) of
        false ->
            ok;
        true ->
            m_my_rsc:create_default_edges(Id, Context),
            ok
    end;
observe_rsc_update_done(#rsc_update_done{}, _Context) ->
    %% Fall through
    ok.

Edit on GitHub

rsc_update Resource notifications rsc_upload

Referred by

Execute tasks asynchronously using the task queue

The Zotonic task queue lets applications perform tasks asynchronously.