goldenstein64 / Copy

A Luau-specialized module for copying any value with state.
https://goldenstein64.github.io/Copy
MIT License
0 stars 0 forks source link

Create a "copyObject" internally upon call #8

Open goldenstein64 opened 3 years ago

goldenstein64 commented 3 years ago

Possibly required infrastructure for #7

Acts as an internal state the way Instances.ApplyTransform does. It would make some of the code simpler instead of passing behaviors, contexts, etc. and making the argument list too long.

Basically my excuse to use a structure similar to RaycastParams

goldenstein64 commented 3 years ago

Primarily, it would change the function types of replacers and reconcilers.

For replacers:

-- from this
function replacers.type(self, oldValue)
    return self(oldValue)
end

-- to this
function replacers.type(context)
    return context:sub(context.Old)
end

And for reconcilers:

-- from this
function reconcilers.type(self, oldValue, midValue)
    return self:Extend(midValue, oldValue)
end

-- to this
function reconcilers.type(context)
    context:sub(context.New, context.Old)
end