1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/lib/sdk/model/core.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,25 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + */ 1.8 + 1.9 +"use strict"; 1.10 + 1.11 +module.metadata = { 1.12 + "stability": "unstable" 1.13 +}; 1.14 + 1.15 +const { dispatcher } = require("../util/dispatcher"); 1.16 + 1.17 + 1.18 +// Define `modelFor` accessor function that can be implemented 1.19 +// for different types of views. Since view's we'll be dealing 1.20 +// with types that don't really play well with `instanceof` 1.21 +// operator we're gonig to use `dispatcher` that is slight 1.22 +// extension over polymorphic dispatch provided by method. 1.23 +// This allows models to extend implementations of this by 1.24 +// providing predicates: 1.25 +// 1.26 +// modelFor.when($ => $ && $.nodeName === "tab", findTabById($.id)) 1.27 +const modelFor = dispatcher("modelFor"); 1.28 +exports.modelFor = modelFor;