There are multiple types of layers to work from when developing in the ArcGIS API for JavaScript but there are instances where you might want to implement your own custom functionality via a custom layer type. One example is to modify the default drawing behavior of a layer in the map. Extending the GraphicsLayer class and implementing additional functionality can provide custom drawing behavior. Samples are provided below which demonstrate this functionality.
Before you embark on creating custom layer types, it is helpful to have some familiarity with the ArcGIS JavaScript API, especially the Layer class and its associated subclasses.
It's also helpful to be familiar with creating and extending classes using the AMD style of define() and dojo/_base/declare. More information and a helpful tutorial regarding working with dojo/_base/declare can be found at the Dojo toolkit tutorials.
Additional information regarding defining modules and creating classes can be found at:
The following sample demonstrate how to create custom layer types using the above pattern: