michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: "use strict"; michael@0: michael@0: module.metadata = { michael@0: "stability": "unstable" michael@0: }; michael@0: michael@0: const { dispatcher } = require("../util/dispatcher"); michael@0: michael@0: michael@0: // Define `modelFor` accessor function that can be implemented michael@0: // for different types of views. Since view's we'll be dealing michael@0: // with types that don't really play well with `instanceof` michael@0: // operator we're gonig to use `dispatcher` that is slight michael@0: // extension over polymorphic dispatch provided by method. michael@0: // This allows models to extend implementations of this by michael@0: // providing predicates: michael@0: // michael@0: // modelFor.when($ => $ && $.nodeName === "tab", findTabById($.id)) michael@0: const modelFor = dispatcher("modelFor"); michael@0: exports.modelFor = modelFor;