How should I use autoJoin?

After inserting a custom node through the event handler, I want to autoJoin the node that was inserted with the adjacent node that has the same type. It looks like autoJoin from prosemirror-commands will do the job but I am having trouble understanding how I can apply autoJoin to the EditorState.

It can’t be applied to an editor state—you apply it to a command function, and get a wrapped command that will join affected nodes after executing the inner command.