Skip to content

Commit

Permalink
Update README.md to mention singleton classes (#91)
Browse files Browse the repository at this point in the history
The README does not indicate clearly that CustomJS creates singleton instances of classes. While this is useful for some usecases I found this incredibly confusing when trying to create custom classes with constructors.
  • Loading branch information
baweaver committed Jun 7, 2024
1 parent ea92d8d commit fb32da5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ tR += CoolString.coolify(tp.file.title);

Make sure you add `scripts/coolString.js` to the settings page for CustomJS and voila! When entering preview mode for the dataviewjs block you should see a list of all your files with a little extra 😎 — inserting the templater template will output a similar result with just the current file name.

> ⚠️ CustomJS will initialize any class as a singleton instance. If you want to create an isolated instance use `create${className}Instance` instead, such as `createCoolStringInstance` for the above class.
## Advanced example

You can pass anything as parameters to your functions to allow for some incredible code reuse. A dataview example that I use to manage tasks:
Expand Down

0 comments on commit fb32da5

Please sign in to comment.