More explanations in news

This commit is contained in:
Dan Holmsand 2015-12-21 08:14:41 +01:00
parent f49d73a4e4
commit a8be359882
1 changed files with 20 additions and 1 deletions

View File

@ -160,6 +160,7 @@
[:li [:code "next-tick"]" is now guaranteed to execute its
argument before the next render (more on that below.)"]]]
[:h2 "track: Use any function as a reactive value"]
[:p [:code "reagent.core/track"] " takes a function, and
@ -212,12 +213,20 @@
will only result in one call to the " [:code "people"] "
function (both initially, and when the state atom changes)."]]
[:p "If you've been using "[:code "reagent.ratom/reaction"]"
etc, "[:code "track"]" should be quite familiar. The main
difference is that "[:code "track"]" uses named functions and
variables, rather than depending on closures, and that you
dont have to manage their creation manually (since tracks are
automatically cached and reused)."]
[:p [:b "Note: "] "The first argument to "[:code "track"]"
should be a named function, i.e not an anonymous one. Also,
beware of lazy data sequences: dont use deref (i.e ”@”) with
the "[:code "for"]" macro, unless wrapped
in "[:code "doall"]" (just like in Reagent components). "]
[:h2 "track!"]
[:p [:code "track!"]" is another new function. It works just
@ -235,6 +244,7 @@
continue to run until you stop it, using "[:code "(r/dispose!
logger)"]"."]
[:h2 "with-let: Handling destruction"]
[:p "Reagent now has a new way of writing components that need
@ -265,6 +275,10 @@
when " [:code "mouse-pos"] " is no longer tracked anywhere, i.e
in this case when " [:code "tracked-pos"] "is unmounted."]
[:p [:code "with-let"]" can also generally be used instead of
returning functions from components that keep local state, and
may be a bit easier to read."]
[:section.demo-text
[:h2 "Event handling with rswap!"]
@ -320,7 +334,12 @@
trigger warnings due to unexpected return values, and may
cause severe headaches if an event handler called by dispatch
itself dispatches a new event (that would result in lost
events, and much confusion)."]]
events, and much confusion)."]
[:p "For a more structured version of this approach, see the
excellent "[:a
{:href "https://github.com/Day8/re-frame"} "re-frame"]"
framework."]]
[:section.demo-text
[:h2 "New React version and new namespaces"]