{"action":"created","issue":{"url":"https://api.github.com/repos/codemirror/codemirror.next/issues/64","repository_url":"https://api.github.com/repos/codemirror/codemirror.next","labels_url":"https://api.github.com/repos/codemirror/codemirror.next/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/codemirror/codemirror.next/issues/64/comments","events_url":"https://api.github.com/repos/codemirror/codemirror.next/issues/64/events","html_url":"https://github.com/codemirror/codemirror.next/pull/64","id":390787238,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4NDc1NDk1","number":64,"title":"RFC: Behavior","user":{"login":"marijnh","id":144427,"node_id":"MDQ6VXNlcjE0NDQyNw==","avatar_url":"https://avatars3.githubusercontent.com/u/144427?v=4","gravatar_id":"","url":"https://api.github.com/users/marijnh","html_url":"https://github.com/marijnh","followers_url":"https://api.github.com/users/marijnh/followers","following_url":"https://api.github.com/users/marijnh/following{/other_user}","gists_url":"https://api.github.com/users/marijnh/gists{/gist_id}","starred_url":"https://api.github.com/users/marijnh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marijnh/subscriptions","organizations_url":"https://api.github.com/users/marijnh/orgs","repos_url":"https://api.github.com/users/marijnh/repos","events_url":"https://api.github.com/users/marijnh/events{/privacy}","received_events_url":"https://api.github.com/users/marijnh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":31,"created_at":"2018-12-13T17:41:18Z","updated_at":"2018-12-17T10:35:23Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/codemirror/codemirror.next/pulls/64","html_url":"https://github.com/codemirror/codemirror.next/pull/64","diff_url":"https://github.com/codemirror/codemirror.next/pull/64.diff","patch_url":"https://github.com/codemirror/codemirror.next/pull/64.patch"},"body":"This branch contains an implementation of a mechanism that replaces (state) plugins. It works roughly like this:\r\n\r\n - A behavior is an object with <Spec, Value> type parameters\r\n - The Spec parameter is the thing that you pass when loading the behavior, usually a configuration object\r\n - The Value parameter is the thing that consumers of the behavior, if any, can get access to (though the behavior object's `get` method)\r\n - There's two kinds of behaviors—those that manually merge their specs into a single value, and those that just accumulate an array of them (`Value=Spec[]`)\r\n - Instead of plugins, you now pass behaviors parameterized with specs when creating a state\r\n - Behaviors can specify sub-behaviors, and loading a behavior pulls those in\r\n - For behaviors that combine their specs (such as history), a single set of sub-behaviors is used for the entire behavior. For those that accumulate them separately (such as keymap), every spec results in a separate set of sub-behaviors\r\n - When initializing a state, for each behavior, an ordered set of specs is found. For behaviors that combine their specs, the combining function gets the specs in this order. For set behaviors, the set ordering is determined this way\r\n - Each use of a behavior can specify a priority from a set of 4 pre-programmed priorities\r\n - The ordering happens first by priority, then by order, where the order is determined by the order in which the behaviors were given when creating the state, with sub-behaviors inheriting the position of their parent behavior\r\n - Unless explicitly specified, a sub-behavior inherits the priority of its parent\r\n\r\nThe main things that this tries to accomplish is:\r\n - Introduce a generic kind of 'services' that extensions can provide (via a state) and other code can consume\r\n - Allow behaviors to compose other behaviors without causing problems when behaviors are pulled in twice via separate paths\r\n - Provide more control (and access to) the ordering of plugins/behaviors, so that you can for example override a key binding without fine-tuning the order of your plugins (and so that you can override one behavior without having all the behaviors you provide be high-precedence)\r\n\r\nThe approach is a little baroque (though I already put a lot of effort into keeping it minimal), but it seems to meet these goals well. I have, for example, introduced an indentation behavior that the legacy modes now provide, along with generic commands that do indentation, which use this behavior. I haven't tried to wire up tokens with bracket matching yet, but that should be able to work the same way.\r\n\r\nI'd love to hear your comments, @adrianheine "},"comment":{"url":"https://api.github.com/repos/codemirror/codemirror.next/issues/comments/447798168","html_url":"https://github.com/codemirror/codemirror.next/pull/64#issuecomment-447798168","issue_url":"https://api.github.com/repos/codemirror/codemirror.next/issues/64","id":447798168,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Nzc5ODE2OA==","user":{"login":"adrianheine","id":139208,"node_id":"MDQ6VXNlcjEzOTIwOA==","avatar_url":"https://avatars3.githubusercontent.com/u/139208?v=4","gravatar_id":"","url":"https://api.github.com/users/adrianheine","html_url":"https://github.com/adrianheine","followers_url":"https://api.github.com/users/adrianheine/followers","following_url":"https://api.github.com/users/adrianheine/following{/other_user}","gists_url":"https://api.github.com/users/adrianheine/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianheine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianheine/subscriptions","organizations_url":"https://api.github.com/users/adrianheine/orgs","repos_url":"https://api.github.com/users/adrianheine/repos","events_url":"https://api.github.com/users/adrianheine/events{/privacy}","received_events_url":"https://api.github.com/users/adrianheine/received_events","type":"User","site_admin":false},"created_at":"2018-12-17T10:35:23Z","updated_at":"2018-12-17T10:35:23Z","author_association":"COLLABORATOR","body":"If I remember correctly you didn't want the commands to be closures."}}
{"actor":{"display_login":"adrianheine"}}