Skip to content

Improve section on Google Closure import and require #60

Open
@smahood

Description

@smahood

I've just had to use Google Closure directly for the first time, and I found it difficult to understand the nuances in order to get things working properly on a real project even after reading all the documentation and linked blog posts. The areas that were unclear to me:

  • Format to import in a namespace - surround with [ ], ( ), or nothing - particularly when importing multiple dependencies.
  • How to use import when importing multiple namespaces - (:import [goog URI OtherNS]) - the examples didn't explain this clearly to me.
  • Name collisions - for example, OpenLayers has classes ol.source.Vector and ol.layer.Vector - What is the recommended way to work with these? Is there a way to import classes with a namespace to distinguish these?
  • How to use things after importing or requiring them in JS interop - URI. or goog.URI. - this is laid out in a limited form, but I think an example of more extended interop would be very useful.
  • More specific documentation, perhaps with examples, of how to tell whether things are a Closure class or not.

I also think it would be worthwhile to better explain the benefits of using import over require, but with the caveat that everything will still work fine if you just require everything - it may allow other beginners to this part of ClojureScript to get thing working quickly and improve or experiment as they understand things better.

I'm planning to work on a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions