Make `Fig.Generator["trigger"]` more declarative
See original GitHub issueSanity checks
- I have searched github.com/withfig/fig/issues and there are no duplicates of my feature
Feature Details
There are some things that currently happen imperatively that could happen declaratively.
- Token length changes
- Token length changes around a number, eg for 5: from 4>5, 4>6, 6>5, 6>4, etc.
- Final index of one of N strings is changed, instead of just one
type Trigger =
| string
| ((newToken: string, oldToken: string) => boolean)
| { on: "change" }
| { on: "threshold"; length: number }
| { on: "string"; string: string | string[] };
interface Generator {
trigger: Trigger;
}
const _0: Generator = {
// Trigger on every keystroke
trigger: { on: "change" },
}
const _1: Generator = {
// Trigger when length passes 5
trigger: { on: "threshold", length: 5 },
}
const _2: Generator = {
// Trigger when length changes to or from 0
trigger: { on: "threshold", length: 0 },
}
const _3: Generator = {
// Trigger when any of the last index of any of the strings are changed
trigger: { on: "string", string: [":", ","] },
}
// Implementation / equivalent `trigger` functions
// change:
// () => true
// threshold:
// (curr, prev) => (curr.length <= length && prev.length >= length) || (curr.length >= length && prev.length <= length)
// string:
// (curr, prev) => Math.max(...makeArray(strings).map((string) => curr.lastIndexOf(string))) !== Math.max(...makeArray(strings).map((string) => prev.lastIndexOf(string)))
cc @fedeci - are there any extras you can think of? Better names? I think this covers the main use-cases.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Issues · withfig/autocomplete - GitHub
Make Fig.Generator["trigger "] more declarative codebase:autocomplete-app schema Anything related to the spec API type:feature-request.
Read more >Contents - computer science at N.C. State
Also, formal methods are the most effective when included in tools and used ... An important practical consideration is to make the semantics...
Read more >AP5 Reference Manual
First, it allows you to choose a representation of data that you think will make your program more efficient. You can even create...
Read more >Multiagent Systems : A Modern Approach to Distributed ...
To make the above considerations more concrete, a closer look has to be taken on multiagent systems and thus on.
Read more >Grounded discourse representation theory - Academia.edu
This in fact is the intuitively more fundamental type of reference: in order to make referential use of natural language, there must first...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this is a better naming, and I like the idea of having a sugar on top of trigger.
Definitely wouldn’t remove the ability to use a function, but making it simpler to do the most common things is good
Just checked in withfig/autocomplete and this covers almost every case where there’s currently a function for
trigger