Skip to content

[Discussion] Remove changed checks for simple computed properties #415

Closed
@jacobp100

Description

@jacobp100

I have the input,

monthlyAdminCosts: (numDrivers, driverMileageTime, driverSalary, adminMileageTime, adminSalary) =>
  numDrivers * driverMileageTime * driverSalary + adminMileageTime * adminSalary,

Which gives the large output,

if ( isInitial || ( 'numDrivers' in newState && typeof state.numDrivers === 'object' || state.numDrivers !== oldState.numDrivers ) || ( 'driverMileageTime' in newState && typeof state.driverMileageTime === 'object' || state.driverMileageTime !== oldState.driverMileageTime ) || ( 'driverSalary' in newState && typeof state.driverSalary === 'object' || state.driverSalary !== oldState.driverSalary ) || ( 'adminMileageTime' in newState && typeof state.adminMileageTime === 'object' || state.adminMileageTime !== oldState.adminMileageTime ) || ( 'adminSalary' in newState && typeof state.adminSalary === 'object' || state.adminSalary !== oldState.adminSalary ) ) {
  state.monthlyAdminCosts = newState.monthlyAdminCosts = template.computed.monthlyAdminCosts( state.numDrivers, state.driverMileageTime, state.driverSalary, state.adminMileageTime, state.adminSalary );
}

Would it make sense for simple computed properties to not do these checks? We could define a simple computed property as one that does not invoke any functions.

As a quick test, I removed these checks from a simple project, and it decreased the min+gz size by 5%.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions