These are chat archives for ractivejs/ractive

21st
Jan 2018
Chris Reeves
@evs-chris
Jan 21 2018 05:49
regarding use, is it weird that I'd prefer to be able to Ractive.use(one, another, more) and if they need options, Ractive.use(one(something), two, three({ why: 'not?' }))? That leaves it open to the implementer and the user to handle special config
Chris Reeves
@evs-chris
Jan 21 2018 05:55
also, I wouldn't want to have to detect instance vs constructor in the plugin code, so the implementation should abstract that in some way
Paul Maly
@PaulMaly_twitter
Jan 21 2018 07:26
Regarfing first part, I think it's good reason to implement that way. :+1: @fskreuz is also suggest the same variant. So, seems I also agree.
Paul Maly
@PaulMaly_twitter
Jan 21 2018 07:32
Second part, I can't imagine how we can abstruct this in convinient way. But I think this won't a usual case, when plugin should work in both cases. Seems, in most cases plugin will describe how it should be used.
Maybe we just can always pass Ractive constructor as the argument of plugin function, but context will able to be different:
function (Ractive) { Ractive.isInstance(this) }
Paul Maly
@PaulMaly_twitter
Jan 21 2018 07:47
So, we would able to use argument in case when we need the constructor, and context for instance. To secure, we just check the context in clear and simple way
Joseph
@fskreuz
Jan 21 2018 10:31
Instead of multiple args, it could be an array just like Rollup's plugins option. Never been a fan of multiple args, especially if it goes past 3 items. Arrays also newline cleaner than args for some formatters. :D
Ractive.use([
  onePlugin,
  twoPlugin({ ... }),
  three
])
re: constructor vs instance, you could supply both. Except, if you use it on a constructor, the second arg would be undefined. Use it on an instance, it would be that instance.
const MyPlugin = options => (Ractive, instance) => {
  // Ractive.use, instance is undefined
  // instance.use, instance is instance
}
Paul Maly
@PaulMaly_twitter
Jan 21 2018 10:37
Yep, maybe
Regarding args, seems multiple args is in ractive-style
Also you always able to add additional line breaks to format your code more readable
Also multiple args way looks like express middlewares, I believe it's a good point
Joseph
@fskreuz
Jan 21 2018 10:40
I don't really mind multi-args since there's the spread and rest operator. Either way is fine. Ractive.extend does it so consistency I guess. :+1:
Paul Maly
@PaulMaly_twitter
Jan 21 2018 10:42
Yes and many other existing methods like push() for example
Juan C. Andreu
@andreujuanc
Jan 21 2018 16:28
Read both RFC, very good talks. Much wow.
@fskreuz said something about using typescript? :clap:
Port Ractive to TS? :smile:
"Which needs to a rewrite, proposing TypeScript for early safety and strict syntax/structure." :paperclip:
( dreams )
Joseph
@fskreuz
Jan 21 2018 19:54
Long term goal but yeah.