1 ! Copyright (C) 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs digraphs kernel namespaces sequences ;
6 : triggers ( -- triggers )
7 \ triggers global [ drop H{ } clone ] cache ;
9 : trigger-graph ( trigger -- graph )
10 triggers [ drop <digraph> ] cache ;
12 : reset-trigger ( trigger -- )
13 <digraph> swap triggers set-at ;
15 : add-trigger ( key quot trigger -- )
16 #! trigger should be a symbol. Note that symbols with the same name but
17 #! different vocab are not equal
18 trigger-graph add-vertex ;
20 : before ( key1 key2 trigger -- )
21 trigger-graph add-edge ;
23 : after ( key1 key2 trigger -- )
26 : call-trigger ( trigger -- )
27 trigger-graph topological-sorted-values [ call ] each ;