Dataviewjs janky "modules" without CustomJS
I figured this out before I found the CustomJS plugin which I'm going to play with next. It might be useful in situations where CustomJS can't work (if there are any).
`In stuff.js, where stuff is defined:` `input.modules.stuff = {` `myfunc: function() { console.log("Inside myfunc!"); }` `};`
`In view.js, which uses stuff:` `const modules = {};` `await dv.view("path/to/stuff", { modules: modules });`
`modules.stuff.myfunc(); // You'll see the message in the dev console. Ctrl+Shift+I`
`dv.table( ... );`
`In your note's dataviewjs block:`
`dv.view("path/to/view");`
This works because objects are passed by reference (or shared reference or whatever) in Javascript. The input object passed to dv.view isn't cloned before being passed to your view.js file (well, at least not currently), it's just passed directly. This means any mutation you do to the input.module object is usable by view.js.
Edit: I've played around some with CustomJS and it's pretty slick and you should use it instead of my janky pattern. It's still a neat thing to know about and it's something to keep in the back of your mind if you run into other Javascript things that are somehow locked down in Dataview or Obsidian.