@@ -931,7 +931,11 @@ const wrapIfDebug = cond([
931931 } ) ] ,
932932 [ T , identity ] ] ) ;
933933
934- // TODO : use rxdb to replace firebase for the demo - it is totally offline
934+ // TODO : implmement history mechanism in this library
935+ // TODO: actionable implementation of statecharts in hs https://github.com/steelbreeze/state.js
936+ // TODO : fsm http://www.intersel.fr/assets_intersel_a/gitdemos/iFSM/Examples/Example_Slideshow.html
937+ // TODO : use rxdb to replace firebase for the demo - it is totally offline, or
938+ // pipeDb! https://github.com/pipelinedb/pipelinedb
935939// TODO : implement remaining contracts cf. doc
936940// TODO : move contrac for action guards and event guards (return boolean value) into debug:true
937941// so that when debug is false we have better performance
@@ -984,3 +988,145 @@ const wrapIfDebug = cond([
984988// customize anything with D3 BUT graphlib not exportable Conversion
985989// http://openconnecto.me/graph-services/convert/ - for isntance graphML (yed) to DOT (viz.js) NOTE
986990// - graphML is used by yed but also http://igraph.org/redirect.html
991+ // TODO: can be used to have state chart logic for free : https://github.com/FrozenCanuck/Ki/blob/master/frameworks/foundation/system/statechart.js
992+ // but I will have to add the events and change the formats (add transitions in objects instead
993+ // of imperative this.go(state) ) and so on
994+ // And also I should write tests, there are none...
995+ // for google cloud spark back-end C:\Users\toshiba\AppData\Local\Google\Cloud SDK
996+
997+
998+ // Dom driver
999+ // modified .tap(console.log.bind(console, `For namespace ${namespace}, emitting ${type} event:`))
1000+ // in C:\Users\toshiba\WebstormProjects\sparks-cyclejs\node_modules\cycle-snabbdom\lib\events.js
1001+ // Auth driver
1002+ // C:\Users\toshiba\WebstormProjects\sparks-cyclejs\node_modules\@sparksnetwork\cyclic-fire\dist\index.js
1003+ /*
1004+ return rootElement$.first().flatMapLatest(function (rootElement) {
1005+ if (!namespace || namespace.length === 0) {
1006+ return (0, _fromEvent.fromEvent)(rootElement, type, useCapture);
1007+ }
1008+ var simulateBubbling = makeSimulateBubbling(namespace, rootElement);
1009+ return (0, _fromEvent.fromEvent)(rootElement, type, useCapture).filter(simulateBubbling);
1010+ })
1011+ .tap(tapDomEvent(namespace, type))
1012+ .share();
1013+ };
1014+ }
1015+
1016+ function tapDomEvent(namespace, type) {
1017+ return function tapDomEvent(ev) {
1018+ const selection = pick(['clientX', 'clientY', 'path', 'ctrlKey', 'shiftKey', 'type'], ev)
1019+ selection.targetClassName = ev.target ? ev.target.className : ""
1020+ selection.targetId = ev.target ? ev.target.id : ""
1021+
1022+ console.log(`For namespace ${namespace}, emitting ${type} event:`, selection)
1023+ }
1024+ }
1025+
1026+ function pick(arrProps, obj) {
1027+ let res = {}
1028+ arrProps.forEach(key => res[key] = obj[key])
1029+
1030+ return res
1031+ }
1032+ */
1033+ // Queue driver
1034+ // C:\Users\toshiba\WebstormProjects\sparks-cyclejs\node_modules\@sparksnetwork\cyclic-fire\dist\index.js
1035+ /*
1036+ return function (listenerKey) {
1037+ return ChildAddedStream(srcRef.child(listenerKey))
1038+ .tap(console.log.bind(console, `Response received for listenerKey (uid?) : ${listenerKey}`))
1039+ .doAction(function (_ref2) {
1040+ var key = _ref2.key;
1041+ return deleteResponse(srcRef, listenerKey, key);
1042+ });
1043+ };*/
1044+ // building query from fb api is simply mapping the args to chained fn calls
1045+ // C:\Users\toshiba\WebstormProjects\sparks-cyclejs\node_modules\@sparksnetwork\cyclic-fire\dist\index.js
1046+ // firebase driver
1047+ /*
1048+ var build = function build(args) {
1049+ var stream = ValueStream(args.reduce(chain, ref))
1050+ .tap(console.log.bind.console(`firebase query (args, ?)`, args))
1051+ .replay(null, 1);
1052+ var disposable = stream.connect();
1053+ compositeDisposable.add(disposable);
1054+ return stream;
1055+ };
1056+ */
1057+ /*
1058+ action : "create"
1059+ domain : "Assignments"
1060+ uid : "nKyJt64tayMHJ0ucG0Q4A3gQogQ2"
1061+ payload : {
1062+ values : {
1063+ engagementKey : "-KaFkxJRCi60lUlzSsGx"
1064+ oppKey : "-KX9OEk_l6mYeNFtS_mq"
1065+ profileKey : "-KaFkwVPmISpvbyqC_1v"
1066+ shiftKey : "-Ka35opxkYP01tVuiIgL"
1067+ teamKey : "-KXA7guQXeOC7f8Zn8y1"
1068+ }
1069+ }
1070+ */
1071+ /*
1072+ Assignments : {
1073+ -KFsXPXhpr7Jk4m0U_Dt :{
1074+ engagementKey:"-KEyXx_POjDOx4Upiie1" // Engagments
1075+ oppKey:"-KEh5MsHxpWFMa7n-38t" // Opps
1076+ profileKey: "-KEyXp9tXHdH7lBEBvGN" // Profiles
1077+ shiftKey: "-KFe9WZmSNbrt53fkZNr" // Shifts
1078+ teamKey: "-KEh7UYHKVz05E1HOsNY" // teams
1079+ }
1080+ }
1081+ */
1082+ /*
1083+ Profiles : {
1084+ -KR5Wv46CZeQ1iarHQHz : {
1085+ dob
1086+ email
1087+ fullName
1088+ isAdmin
1089+ isEAP
1090+ location
1091+ phone
1092+ portraitUrl
1093+ uid
1094+ }
1095+ }
1096+ */
1097+ /*
1098+ Users : {
1099+ JGhKXoFvpURntzyNBYzr5CAqeSp2: "-KYLI7kW6nVlVRmFG5v2"
1100+ }
1101+ */
1102+ /*
1103+ Shifts : {
1104+ -KMwPqNFWph2BEBEvyIQ : {
1105+ assigned : 2 // number of people assigned to that shift??
1106+ date : "2016-07-30T00:00:00-04:00"
1107+ end : "2016-07-30T16:00:00-04:00"
1108+ hours : 4
1109+ ownerProfileKey : "-KEMTVUivQTtyS8eYqKg" // ??
1110+ people
1111+ reserved
1112+ start : "2016-07-30T12:00:00-04:00"
1113+ teamKey : "-KMW9UO1IkMjRjc6ZqB2" // shift belongs to that team, Teams
1114+ }
1115+ }
1116+ */
1117+ const shifts$ = sources . teams$
1118+ . map ( map ( prop ( '$key' ) ) )
1119+ . flatMapLatest (
1120+ compose (
1121+ combineLatest ,
1122+ map ( Shifts . query . byTeam ( sources ) ) ,
1123+ )
1124+ )
1125+ . map ( flatten )
1126+ . map ( uniqBy ( prop ( '$key' ) ) )
1127+ . map ( sortBy (
1128+ compose (
1129+ localTime ,
1130+ prop ( 'start' ) ,
1131+ )
1132+ ) )
0 commit comments