Update base objects to use static and merge for configurable attributes.

Review Request #12909 — Created March 22, 2023 and submitted

Information

Spina
master

Reviewers

Starting in Spina 2, BaseModel, BaseView, and BaseCollection's
configurable attributes are now defined as static, allowing them to be
accessed outside of instances. This is important for subclasses.

These make use of the new prototypeAttrs option, which ensures they'll
be accessible on the prototype, allowing Backbone to behave as normal
and for instances to continue accessing using this.

Types for both the static and instance/prototype versions are set on
these base classes. Since static is incompatible with generics, we use
the most base type for these there, but the ones on the prototype are
typed as expected. Subclasses may still define types for their versions.

Some attributes (events, modelEvents, and defaults) are also set
up to auto-merge between parents/subclasses. This means that subclasses
no longer have to manually call _.defaults or _.extends, passing in
the parent class's attribute (but at the same time, it won't hurt if
they still do). This will keep things more maintainable going forward.

Porting existing code in Review Board to set the appropriate attributes
as static, and verified that instances and subclasses could properly
access and extend these.

Summary ID
Update base objects to use static and merge for configurable attributes.
Starting in Spina 2, `BaseModel`, `BaseView`, and `BaseCollection`'s configurable attributes are now defined as `static`, allowing them to be accessed outside of instances. This is important for subclasses. These make use of the new `prototypeAttrs` option, which ensures they'll be accessible on the prototype, allowing Backbone to behave as normal and for instances to continue accessing using `this`. Types for both the `static` and instance/prototype versions are set on these base classes. Since `static` is incompatible with generics, we use the most base type for these there, but the ones on the prototype are typed as expected. Subclasses may still define types for their versions. Some attributes (`events`, `modelEvents`, and `defaults`) are also set up to auto-merge between parents/subclasses. This means that subclasses no longer have to manually call `_.defaults` or `_.extends`, passing in the parent class's attribute (but at the same time, it won't hurt if they still do). This will keep things more maintainable going forward.
0e1a219230fdcce2dc26d39064d0ef66c00815f8
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (c75bd9d)