Commit Graph

302 Commits

Author SHA1 Message Date
Mike Thompson f6d191f425 Better docs on new effect 2016-07-15 18:46:16 +10:00
Mike Thompson 927d2c03a1 remove laziness 2016-07-15 14:15:30 +10:00
Mike Thompson 9294adb1b5 Improve warning message if incorrect use of fx detected. 2016-07-15 11:40:07 +10:00
Mike Thompson daf070b1fd Merge branch 'develop' of https://github.com/Day8/re-frame into develop 2016-07-15 11:34:42 +10:00
Mike Thompson 800a1a2d6b closer now to having :forward-events working. 2016-07-15 11:33:35 +10:00
Mike Thompson d0827bb578 Update comment for the new world 2016-07-15 11:33:07 +10:00
Mike Thompson 40d0a749d4 Remove incorrect use of re-frame.middleware/fx (should have been re-frame.fx/fx) 2016-07-15 11:32:44 +10:00
snowell 0f117eaac7 Insignificant typo correction in console output (#177) 2016-07-15 10:36:07 +12:00
Mike Thompson 2c9d140c22 Initial fx code now in. But it remains largely untested. 2016-07-14 16:41:54 +10:00
Mike Thompson b75ec509bb Further towards fx 2016-07-14 00:32:36 +10:00
Mike Thompson 5572e6ebf1 Checkpoint. Further Miscellaneous work towards Effectual Handlers 2016-07-13 16:28:15 +10:00
Mike Thompson b395ef40de Update and clarify in changes document. 2016-07-11 16:52:05 +10:00
Mike Thompson 0d31e3c7c6 Cut v0.8.0-alpha1 2016-07-07 14:52:13 +10:00
Mike Thompson 8747d2b14a Move to using reg-sub (rather than register-sub-pure) 2016-06-24 23:15:00 +10:00
Mike Thompson cbef1ec268 Remove use of specific loggers. Everything now goes through re-frame.loggers/console. 2016-06-24 22:56:30 +10:00
Mike Thompson 72397eb6e7 Improve code layout in loggers. 2016-06-24 22:15:24 +10:00
Mike Thompson 6cb23b60a5 Put loggers into their own namespace 2016-06-24 22:09:07 +10:00
Mike Thompson d384da1c75 Alter wording in comments. 2016-06-24 21:31:12 +10:00
Mike Thompson a8b35cd9f1 Improve comment on function 2016-06-24 18:49:42 +10:00
Mike Thompson 5656f79f06 Improve warning message. 2016-06-24 18:26:45 +10:00
Mike Thompson 0b2bcbe65e Complete undo/redo work 2016-06-23 23:41:20 +10:00
Stuart Mitchell f4fb65037e Subscriptions sugar - changed to provide a singleton 2016-06-22 15:41:22 +12:00
Stuart Mitchell 5c7d4ea3d1 Bug Fix for undo tests 2016-06-22 14:30:15 +12:00
Stuart Mitchell addc55658e Bug fix for undo.cljs 2016-06-22 13:34:25 +12:00
Mike Thompson 9452998e0b WIP. undo test fails. 2016-06-22 10:54:41 +10:00
Mike Thompson d03ef7bc7a remover excessive whitespace 2016-06-14 22:45:57 +10:00
Mike Thompson af2fd0b21f Merge branch 'develop' of https://github.com/Day8/re-frame into develop
Conflicts:
	src/re_frame/subs.cljs
2016-06-14 21:14:49 +10:00
Mike Thompson 4741cd73d3 Better naming and comments. 2016-06-14 21:10:56 +10:00
Mike Thompson 6250c584da Add undo API 2016-06-14 21:09:21 +10:00
Mike Thompson 2822dc064a Put all undo related into a single namespace. Change the way middleware factories are done. 2016-06-14 21:08:32 +10:00
Stuart Mitchell 5a4d78ecc8 register-pure-sub: moved into correct namespace 2016-06-14 14:52:37 +12:00
Stuart Mitchell 1b698b3d8f register-pure: added code to enable spec checking of the fn args 2016-06-14 14:52:37 +12:00
Stuart Mitchell 48a1bda438 register-pure-sub: uses a function to do the work 2016-06-14 14:52:25 +12:00
Mike Thompson ea1e9e7745 Light improvements to comments in core. 2016-06-11 22:23:53 +10:00
Mike Thompson 5a214fc83b Fix bug which meant that post-event-callbacks were not called for `dispatch-sync` 2016-06-04 00:13:41 +10:00
Mike Thompson 9adf4cf40b Improve API comment 2016-06-03 12:58:06 +10:00
Mike Thompson 5684543b1a Introduce new API - `remove-post-event-callback` 2016-06-03 12:49:49 +10:00
Mike Thompson 053771ad9d Breaking change to logging 2016-05-31 07:50:49 +10:00
Mike Thompson 3d4e8cde8f Introduce de-duplicated subscriptions. 2016-05-29 23:23:17 +10:00
Mike Thompson c7fb38becf Error message made more generic 2016-05-29 22:48:18 +10:00
Mike Thompson e562b06880 Better router loop comments 2016-05-29 22:47:25 +10:00
Mike Thompson fe1b6bc729 improve trivial comment 2016-05-27 12:54:42 +10:00
Mike Thompson 45e0baee30 Get rid of code for Reagent pre-0.6.0. Plus add more comments. 2016-05-21 00:44:54 +10:00
Mike Thompson 5aafe09c1b Add link to alternative debug middleware 2016-05-21 00:44:16 +10:00
Mike Thompson 41593509be Improved comment 2016-05-20 22:36:35 +10:00
Daniel Compton 477459bae0 Fix grouping of debug/middleware 2016-05-05 12:40:02 +12:00
Daniel Compton c085ac8bb0 middleware/debug: Log a single line if app-db not changed by a handler
middleware/debug logs a group to the console even if there has been no
change to app-db. This makes it harder to tell if you've made a mistake
in refactoring, as the same log message will be shown whether or not
app-db is changing.

This change will log a single line if app-db is not changed by a handler

Fixes #166
2016-05-05 11:56:09 +12:00
Mike Thompson c182af1b59 Add comment on middleware 2016-03-22 14:11:21 +11:00
Mike Thompson 9b64df912d Actually remove log-ex. Commented out in last release. 2016-03-15 20:08:25 +11:00
Mike Thompson 9795a00ec7 Tweak debug middleware output so that exceptions don't get lost in collapsed Groups. 2016-03-14 23:32:24 +11:00
Mike Thompson f821c99858 Remove `log-ex` middleware - no longer needed 2016-03-14 21:00:33 +11:00
Mike Thompson 2c2c1c6612 Take out "experimental" comment near `on-changes`. It became official some time ago. 2016-02-26 23:01:54 +11:00
Mike Thompson 3246265483 Added one tick of extra pause when events have `:flush=dom` metadata. Previously, there were odd times when the pause wasn't enough. 2016-02-26 14:24:34 +11:00
Daniel Compton 41cf9951d8 Add tests for undo behaviour
Inspired by #149, this adds tests to cover the change that was made. It
also tests the redo logic.
2016-01-28 23:14:43 +13:00
Sergey Tselovalnikov bb78981e1d Fix behavior with large undo lists 2016-01-28 21:31:08 +13:00
Markus Bertheau 4115e410d6 Correct spelling 2016-01-23 18:07:20 +13:00
Markus Bertheau 4822688a62 Correct doc reference to handlers/register-base 2016-01-23 18:07:00 +13:00
Mike Thompson 00f706688a Make router work with 0.6.0 of reagent (and be backwards compatible) 2015-12-22 00:17:33 +11:00
Mike Thompson 8c01555a6a Further docs tweaks for v0.6.0 2015-12-09 07:40:47 +11:00
Mike Thompson 2ce82d9fda Add docs for new `add-post-event-callback`. Promote `on-change` to officially being a part of the API. 2015-12-08 08:19:59 +11:00
J. Pablo Fernández 4b84166566 Call the appropriate add-post-event-callback. For #118. 2015-12-06 19:10:32 +00:00
Mike Thompson 927d318626 First pass at providing what @pupeno needs for #118 2015-12-06 23:19:11 +11:00
Stephen C. Gilardi e77fc53e53 simplify state handling around resume 2015-11-06 23:04:45 -05:00
Stephen C. Gilardi 4a3d951568 direct call to -run-queue from resume
- this now happens in the :running state
  - just like a run-queue, but with an unconditional handling of the
    first item on the queue
- no need to trigger here
2015-11-06 23:03:07 -05:00
Stephen C. Gilardi fc9fa490a6 reorder to be the same as the order in the prototype 2015-11-06 23:01:55 -05:00
Stephen C. Gilardi bde07088a4 simplify names: pause, resume, regularize run-queue
- pause-run -> pause
- begin-resume -> resume
  - no longer a multi-step process
- begin-run -> run-queue
  - so all action function names match their keywords
2015-11-06 22:58:15 -05:00
Stephen C. Gilardi 38120c4913 fix a couple of comment typos 2015-11-06 22:50:50 -05:00
mike-thompson-day8 c80549ec95 Merge of #128. Thanks to @nowprovision 2015-11-05 11:08:45 +11:00
Stephen C. Gilardi 6551c010b3 make run-queue more compact 2015-11-04 15:36:41 -05:00
Stephen C. Gilardi aedafd1ac9 doc string edits 2015-11-04 09:15:53 -05:00
Stephen C. Gilardi ffa676744d a few minor comment mods 2015-11-04 09:15:53 -05:00
Stephen C. Gilardi 6751414320 some light editing of the router loop explanation
- preserving all the flavor
2015-11-04 09:15:53 -05:00
Stephen C. Gilardi 4533d51fbe regularize fsm code formatting
- full align vectors on the left side within a group
- one space between left and right side
- align # marks in vectors on the right side within a group
- also arg1 -> arg
2015-11-04 09:15:52 -05:00
Stephen C. Gilardi 08e8b450ee optimize and DRY up pause-run handling 2015-11-04 09:15:52 -05:00
Stephen C. Gilardi ceafa00483 update/minimize ns form for new impl 2015-11-04 08:07:33 -05:00
mike-thompson-day8 075af4bee2 rename action function, plus use 'case' for performance 2015-11-04 17:11:42 +11:00
Stephen C. Gilardi 4be6227b02 revise fsm terminology around resuming 2015-11-04 00:14:11 -05:00
Stephen C. Gilardi b32aeab413 fix [:do-paused :add-event] state transition 2015-11-04 00:10:28 -05:00
mike-thompson-day8 46c627430f Wording changes in docs 2015-11-04 13:33:50 +11:00
mike-thompson-day8 e9a3b1ebeb Improve wording of comments 2015-11-02 23:43:19 +11:00
mike-thompson-day8 420e42aacc Introduce a router loop, not based on core-async 2015-11-02 22:37:46 +11:00
Daniel Compton a2e8c09775 Use yield instead of (timeout 0)
(timeout 0) resolves to using js/setTimeout which will actually take 4+
msecs in browsers. This is an eternity. The nextTick approach was
proposed by Patrick O'Brien and implemented here.

Docs on nextTick from Closure library:

Fires the provided callbacks as soon as possible after the current JS
execution context. setTimeout(…, 0) takes at least 4ms when called from
within another setTimeout(…, 0) for legacy reasons.

This will not schedule the callback as a microtask (i.e. a task that can
preempt user input or networking callbacks). It is meant to emulate what
setTimeout(_, 0) would do if it were not throttled. If you desire
microtask behavior, use goog.Promise instead.
2015-10-16 14:49:10 +13:00
Daniel Compton 3e8f1e1dfa Log warning when non reactive parameters are passed to dynamic subscriptions
Closes #115
2015-10-16 14:47:15 +13:00
Daniel Compton 518ff995dc Remove extra level of indirection when creating dynamic subscription
Instead of creating a RAtom and resetting into it on a seperate side
chain of our dependency graph, we can instead return a reaction which is
the result of @@sub, achieving the same goals but with less code and
complexity.
2015-10-16 14:47:15 +13:00
Daniel Compton 7e492930e3 Add dynamic subscriptions to re-frame
Dynamic subscriptions allow the user to specify subscriptions that
depend on Ratoms/Reactions and will be rerun when they change. Users
will subscribe with v and a vector of dynamic values. The dynamic values
are dereffed and passed to the handler-fn. Dynamic subscriptions need to
pass a fn which takes app-db, v, and the dereffed dynamic values.

Every time a dynamic value changes, handler-fn will be rerun. This is in
contrast to standard subscriptions where handler-fn will only be run
once, although the reaction that it produces will change over time.

A concrete example of the need for this is:
1. You want to subscribe to a query on a remote server which will return
a Reaction which changes in response to server changes.
2. You want this subscription to be able to be rerun when you change one
of the query parameters.

In the current system, all views need to be aware of the possibility of
changing parameters and provide them in their subscriptions.

Example usage code:

(register-sub
  :todo-dynamic
  (fn todo-dynamic [_ _ [active-list]]
    (let [q (q/get-query active-list)]
      q)))

(register-sub
  :todos
  (fn todos [db _]
    (let [active-list (subscribe [:active-list])
          todos       (subscribe [:todo-dynamic] [active-list])]
      (make-reaction (fn todo-vals [] (update @todos :result #(vals (:list %))))))))
2015-10-16 14:46:54 +13:00
Daniel Compton 2720b27e4c Merge pull request #100 from thenonameguy/patch-2
Use if-not instead of (if (not))
2015-09-12 20:27:35 +12:00
Daniel Compton 915ad9a351 Merge branch 'master' into develop
Conflicts:
	README.md
	examples/todomvc/src/todomvc/db.cljs
2015-07-27 16:51:22 +12:00
Szabó Krisztián e0c816859f Use if-not instead of (if (not)) 2015-07-26 19:57:17 +02:00
Daniel Compton b566c08f40 Merge pull request #84 from ducky427/patch-1
Minor code cleanup
2015-07-25 07:44:22 +12:00
Szabó Krisztián 72b2889f94 Fix spelling of 'weird'
https://en.wiktionary.org/wiki/wierd
2015-07-24 15:43:40 +02:00
Stuart Mitchell 62251dfe2b fixed issue with log groupings 2015-07-17 14:16:56 +12:00
Stuart Mitchell 8caee1115b fixes bug introduced by 8af8c6840f 2015-07-17 11:51:34 +12:00
Ducky fc9da0d13a Minor code cleanup 2015-07-16 17:25:54 +01:00
Earl St Sauver 9326a411e7 Simplify implementation of Middleware Compose
The implementation of middleware compose is duplicating behavior already
in compose.

`(apply comp [])` returns identity.
2015-07-11 11:52:23 +07:00
mike-thompson-day8 78dacf5ca1 Fix #65 2015-05-28 23:15:47 +10:00
mike-thompson-day8 16242cc2c4 Merge branch 'master' into develop 2015-05-26 21:53:16 +10:00
Daniel Compton 409b001e26 Clean up spelling, tense, and docstrings 2015-05-26 09:37:10 +12:00
mike-thompson-day8 0aee218689 Improve comments on router. 2015-05-08 15:49:48 +10:00
mike-thompson-day8 25ed816603 When an exception bubbles out of the router loop, it now restarts itself.
Previously the  the router loop was permanently broken by an exception.
This change makes figwheel debugging work much more nicely in some circumstances.
Plus it means that in production, apps have a chance at recovery from UHE
2015-05-02 10:52:11 +10:00
mike-thompson-day8 b921fa497d More "error" use instead of "warn" 2015-05-02 10:49:27 +10:00
mike-thompson-day8 7ebfc2a9ba Start using "error" instead of "warn" for bad things 2015-05-02 10:48:31 +10:00
mike-thompson-day8 36b88a7378 Get logging working 2015-05-02 10:47:37 +10:00
mike-thompson-day8 be8f5b1cc5 Improve comments around logging 2015-05-02 10:46:05 +10:00
mike-thompson-day8 7d85dbca48 Remove unneeded require 2015-04-27 07:39:17 +10:00
mike-thompson-day8 5a32049452 Improve comment 2015-04-27 07:38:48 +10:00
mike-thompson-day8 65c93cd4d1 Implement #53 2015-04-27 07:38:37 +10:00
mike-thompson-day8 87b3572baa Correct comment 2015-04-27 06:05:06 +10:00
mike-thompson-day8 c1fe51ddfd Partially fix #43 by adding ability to clear both kinds of handlers. 2015-04-25 09:50:46 +10:00
mike-thompson-day8 82b3c87f80 Introduce reaction-like middleware. Closes #50 2015-04-25 00:06:51 +10:00
mike-thompson-day8 e80c6c94b3 Improve comment 2015-04-24 23:46:27 +10:00
hipitihop 2571cb5e0b undo
- change undo to support separate event :purge-redos
- bump to [org.clojure/clojurescript "0.0-3211"]
2015-04-24 16:12:14 +10:00
hipitihop 06f7a29583 undo
- add optional parameter clear-redos? to :undo handler. Defaults to false so this is backward compatible.
2015-04-23 15:44:57 +10:00
mike-thompson-day8 72b605340e Bump various for a v0.3.2 release 2015-04-22 00:18:31 +10:00
mike-thompson-day8 6ed3ba1e1f Fix #42 2015-04-22 00:16:55 +10:00
mike-thompson-day8 f5ed759767 Incorporate changes from #46 2015-04-18 21:15:53 +10:00
mike-thompson-day8 76ee67de10 Improve comments and warnings.
Continue process of nicely naming of anon fns, so as to get better stack traces.
2015-04-18 17:59:40 +10:00
mike-thompson-day8 5602bffc6b WIP on subs 2015-04-17 23:51:29 +10:00
mike-thompson-day8 769723c069 add log-ex to core API 2015-04-17 22:51:03 +10:00
mike-thompson-day8 fa954e5d9f Give middleware anonymous handler functions better names, so they are more meaningful in stack traces 2015-04-16 16:02:19 +10:00
mike-thompson-day8 89f5344a86 Correct wiki links 2015-04-08 09:12:47 +10:00
mike-thompson-day8 f5ee682487 Follow suggestion from @whodidthis and include "v" into after and enrich 2015-03-17 22:03:21 +11:00
mike-thompson-day8 ef9dad529a Correct stack access 2015-03-15 20:10:54 +11:00
mike-thompson-day8 a5b1ccdb16 Add log-ex middleware. 2015-03-14 09:47:16 +11:00
Stuart Mitchell 6cb43207ec better printing of errors from re-frame 2015-03-11 16:46:16 +13:00
hipitihop 4426ed278b undo
- correct clear-history! to reset app-explain
- fix subscription :undo-explanations to only con app-explain when there are undos
2015-03-10 15:57:26 +10:00
mike-thompson-day8 0c000f0094 wording in warning 2015-03-06 19:04:27 +11:00
mike-thompson-day8 6a140f9241 Undo tweaks 2015-03-06 19:04:02 +11:00
mike-thompson-day8 ce6a04f68a Merge branch 'develop' of https://github.com/Day8/re-frame into develop 2015-03-06 18:10:27 +11:00
mike-thompson-day8 13840ed9a1 make path easier to use. Note new usage docs. Modify other docs in the process. 2015-03-06 18:06:25 +11:00
hipitihop ecda398c5a undo
- conj app-explain to :undo-explanations subscription
- add optional argument to :undo :redo handlers to specify number of undos/redos. Default 1 when not specified.
- correct comment and event name typos
2015-03-06 16:23:33 +10:00
mike-thompson-day8 a180df85c8 core.sync completely trashes the stack in an exception. Print any exception to the console before that happens. 2015-03-06 12:44:22 +11:00
mike-thompson-day8 f0fbea41a9 Various 2015-03-06 11:40:30 +11:00
mike-thompson-day8 b5ec3c6db5 Reimpliment undo so as to handle explanations 2015-03-06 10:48:20 +11:00
mike-thompson-day8 0ebb46cb91 undoable is now a middleware factory 2015-03-06 10:48:00 +11:00
mike-thompson-day8 a48f55ff79 With pure much more firmly embedded as mandatory middleware, remove a couple of checks 2015-03-05 14:43:11 +11:00
mike-thompson-day8 94afb7a7a1 Switch to renames. 2015-03-05 11:57:00 +11:00
mike-thompson-day8 de9e492bdc derive -> enrich 2015-03-05 11:32:36 +11:00
mike-thompson-day8 816f79f81e Sadly can't use derive. There's a function call that in the standard library apparently. Use enrich instead. 2015-03-05 11:31:46 +11:00
mike-thompson-day8 3b8643cc01 Use the new low level API for non-pure handlers. 2015-03-05 11:31:02 +11:00
mike-thompson-day8 6c55235160 Better explanation of router's handling of exceptions. 2015-03-05 10:41:50 +11:00
mike-thompson-day8 a7f5aca490 improve comment 2015-03-05 10:40:21 +11:00
mike-thompson-day8 d49bb49fd3 Rename register-pure-handler 2015-03-05 10:40:02 +11:00
mike-thompson-day8 e028034f48 Work on explaining the importance if derive 2015-03-05 10:39:09 +11:00
mike-thompson-day8 c6c6bfebf1 Give better names in middleware to improve stack traces 2015-03-05 00:47:03 +11:00
mike-thompson-day8 94e7a35c5f Add and remove comments 2015-03-05 00:45:58 +11:00
mike-thompson-day8 6c63ad315c Various improvements to middleware, mostly comments 2015-03-05 00:01:44 +11:00
mike-thompson-day8 ee5ba0ae01 Better comment 2015-03-05 00:01:03 +11:00
mike-thompson-day8 3540d7da9d Split handlers.cljs in two, creating router.cljs 2015-03-05 00:00:36 +11:00
mike-thompson-day8 470da75c48 WIP 2015-03-04 17:13:02 +11:00
mike-thompson-day8 ecead71638 Merge branch 'develop' of https://github.com/Day8/re-frame into develop 2015-03-03 16:33:46 +11:00