garrensmith commented on a change in pull request #1165: Remove dependency with Backbone.Model URL: https://github.com/apache/couchdb-fauxton/pull/1165#discussion_r245924006
########## File path: app/core/data/model.js ########## @@ -0,0 +1,138 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +import { sendRequest, isObject } from './helpers'; + +/** + * A replacement for Backbone.Model that only depends on 'fetch' and 'Promise'. + * Note it's not intended to be a full replacement for Backbone. It only replicates + * the Backbone.Model functions required by Fauxton. + * + * @export + * @class Model + */ +export default class Model { + + attributes = {}; + exists = false; + isDirty = false; + + /** + *Creates an instance of Model. + * @param {*} attributes + * @param {*} [options={}] + * @memberof Model + */ + constructor(attributes, options = {}) { + if (attributes) { + this.attributes = attributes; + } + if (options && options.collection) { + this.collection = options.collection; + } + this.initialize(attributes, options); Review comment: Since we doing a major change here, could we remove the initialize and just setup everything in the constructor. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
