These are chat archives for ractivejs/ractive

2nd
Nov 2017
Joseph
@fskreuz
Nov 02 2017 00:23
Ractivebars... is the .rbs extension taken? :grin:
Chris Reeves
@evs-chris
Nov 02 2017 00:28
in my head I turned that into a combo of rbf and ibs
Chris Reeves
@evs-chris
Nov 02 2017 00:38
is fairly fitting though... interactive handlebars
"unlike most mustaches, these are interactive"
Joseph
@fskreuz
Nov 02 2017 01:02
but it's missing an "r" :D
Joseph
@fskreuz
Nov 02 2017 01:12
.ribs :joy:
Chris Reeves
@evs-chris
Nov 02 2017 01:13
so a partial would become a riblet?
not the most popular, smallest, or fastest frontend library, but definitely friendly, versatile, and the tastiest
Joseph
@fskreuz
Nov 02 2017 01:32
:joy:
Chris Reeves
@evs-chris
Nov 02 2017 05:53
for self-registering plugins - I think I've settled on a method that isn't too awful. Each component/event/decorator in the file calls a globalRegister function
const win = typeof window !== 'undefined' ? window : null;

export default function globalRegister(name, registry, constructor) {
  if (win && win.Ractive && typeof win.Ractive[registry] === 'object') {
    let script = document.currentScript;
    if (!script) {
      script = document.querySelectorAll('script[data-alias]');
      script = script[script.length - 1];
    }

    if (script) {
      let aliases = script.getAttribute('data-alias');
      if (aliases) {
        aliases = aliases.split('&');
        aliases = aliases.reduce((a, c) => {
          const [k, v] = c.split('=');
          a[k] = v;
          return a;
        }, {});
      }

      if (aliases[name]) Ractive[registry][aliases[name]] = constructor;
    }
  }
}
as it sits, this requires you to specify the name you want to give the plugin in its registry when loading the plugin e.g.
<script src="someComponent.js" data-alias="SomeComponent=thing"></script>
someComponent.js has to call globalRegister('SomeComponent', 'components', SomeComponent) after creating SomeComponent
I don't suppose it would hurt to automatically use the given name and not require an alias to be present, but I definitely like being able to set the name from a script attribute
Chris Reeves
@evs-chris
Nov 02 2017 05:59
it should play nicely with things like jsdelivr bundling for those who just want to play around with a browser and text editor
or is that all going to far to be beginner/casual use friendly?
Cerem Cem ASLAN
@ceremcem
Nov 02 2017 10:23
that seems handy, but seems complex for beginners, IMHO
kouts
@kouts
Nov 02 2017 10:29
@evs-chris what is this for?
Joseph
@fskreuz
Nov 02 2017 12:11
Ractive and most of its plugins are written in ES and use Rollup to bundle into a UMD for older module systems.
By default UMD modules export in either AMD, CJS or a global.
Global is the last place you'd want to stick a plugin. This function, should the plugin author chose to do so, will register the plugin to an existing Ractive instead.
kouts
@kouts
Nov 02 2017 12:13
ahhh ok
nice!
Joseph
@fskreuz
Nov 02 2017 12:14
In the ancient times (a few years ago in JS time :joy: ) we wrote UMD by hand (see ractive-decorator-sortable) and stuck this logic at the end.
Now if only rollup allowed you to customize the UMD header... Hmm...
Chris Reeves
@evs-chris
Nov 02 2017 20:37
0.9.9 has been unleashed upon the world
Joseph
@fskreuz
Nov 02 2017 20:39
:tada:
kouts
@kouts
Nov 02 2017 20:49
:sparkles:
Cerem Cem ASLAN
@ceremcem
Nov 02 2017 21:23
:+1:
Chris Reeves
@evs-chris
Nov 02 2017 22:23
for anyone who does intranet apps with ractive, I've finally started working on publishing my go-to component library
there's still a good bit missing and there are almost no docs
but I find desktop-style MDIs that respond all the way down to mobile fun, so it's up for anyone else interested in that sort of thing too
Martin Kolárik
@MartinKolarik
Nov 02 2017 22:52
:tada:
Joseph
@fskreuz
Nov 02 2017 23:00
Nice name :D
On second thought, I'll add it right now :D