These are chat archives for ractivejs/ractive

31st
Mar 2018
Paul Maly
@PaulMaly_twitter
Mar 31 2018 14:16
HOC example with Ractive: playground.
I still don't understand why Reactivists so rush with that HOCs
Paul Maly
@PaulMaly_twitter
Mar 31 2018 14:58
@evs-chris Btw, example from docs with extendWith() not working.
Uncaught Error: Only classes that inherit the appropriate prototype may be used with extend
Chris Reeves
@evs-chris
Mar 31 2018 15:06
ah, derp. That should be class Widget extends Ractive {
on the first line
Paul Maly
@PaulMaly_twitter
Mar 31 2018 15:11
)))
It should be a ES6 Class or could be Ractive's component too?
Paul Maly
@PaulMaly_twitter
Mar 31 2018 15:16
const Component = Ractive.extend({...});

const ComponentExtended = Ractive.extendWith(Component, {...})
?
Chris Reeves
@evs-chris
Mar 31 2018 15:18
a SomethingRactivey.extend(...) or a class Component extends SomethingRactivey {...}; SomethingRactivey.extendWith(Component, {...})
extendWith doesn't return anything (I think), it just modified the given constructor
Paul Maly
@PaulMaly_twitter
Mar 31 2018 15:20
Returns
(Function): The augmented constructor function.
)))
Chris Reeves
@evs-chris
Mar 31 2018 15:22
ah, yes it does, I just never use it cause it's === SomethingRactivey in the example 😄
wait, I mean === Component
I really should stop trying to gitter on mobile 😅
Paul Maly
@PaulMaly_twitter
Mar 31 2018 15:24
Actually, I still don't understand the case where it needed.
If Widget is a simple class extended from any parent class, it's ok
but if Widget extends Ractive, I don't understand purpose of this
Chris Reeves
@evs-chris
Mar 31 2018 15:25
extendWith installs all of the ractive init vars onto the constructor, which the prototype class know nothing about
otherwise, how would the class know about template, css, on, etc
we could avoid the extends requirement if extendWith modified the target prototype chain, but I don't think that works reliably on older browsers that we still support
Paul Maly
@PaulMaly_twitter
Mar 31 2018 15:30
I like old extend() and it's great for mixins approach
Chris Reeves
@evs-chris
Mar 31 2018 15:55
that's fair... I only use extendWith when I want the component function name to be something other than 'Child', like for reusable components or primary views in a large app
Paul Maly
@PaulMaly_twitter
Mar 31 2018 16:01
I never give a names to my components, just export them from their files ))