From 49815c602849373e9b3e06affaaa58d773debc67 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Fri, 27 Jan 2017 22:58:45 -0800 Subject: [PATCH] docs: component.onunload was removed --- docs/change-log.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/change-log.md b/docs/change-log.md index e25932bb..beec9e40 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -29,6 +29,7 @@ If you are migrating, consider using the [mithril-codemods](https://www.npmjs.co - [Reading/writing the current route](#readingwriting-the-current-route) - [Accessing route params](#accessing-route-params) - [Preventing unmounting](#preventing-unmounting) +- [Run code on component removal](#run-code-on-component-removal) - [`m.request`](#mrequest) - [`m.deferred` removed](#mdeferred-removed) - [`m.sync` removed](#msync-removed) @@ -489,6 +490,40 @@ var Component = { --- +## Run code on component removal + +Components no longer call `this.onunload` when they are being removed. They now use the standardized lifecycle hook `onremove`. + +### `v0.2.x` + +```javascript +var Component = { + controller: function() { + this.onunload = function(e) { + // ... + } + }, + view: function() { + // ... + } +} +``` + +### `v1.x` + +```javascript +var Component = { + onremove : function() { + // ... + } + view: function() { + // ... + } +} +``` + +--- + ## m.request Promises returned by [m.request](request.md) are no longer `m.prop` getter-setters. In addition, `initialValue`, `unwrapSuccess` and `unwrapError` are no longer supported options.