Prompt Cursor to Create New Function API with Composer Context

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 2 months ago
Updated 2 weeks ago

Another great use-case for Cusor Composer is to handle creating new API that is similar to previous functions that you've already written.

In this lesson we'll give composer context of two of our files and a line of code to extract logic into an API for our application to use.

[00:00] I'm going to select this line of code, hit command I, and then you can see that that line and the two files that are open in my tabs are in my context. So I want to extract the appearance logic and expose a set appearance API. Then just by hitting enter, it will start working through my files, and we can check what it did down here. You can see that it added [00:19] the set appearance method here. It followed the patterns of adding logs from my other methods and then set up all the logic around dark and light. And then it also, in my index file, it exposed the set appearance method so that it calls the add on with the proper values here. So I'm just going to accept all. And now we have a working set appearance [00:39] API across multiple files simply based on the one line I had selected and a prompt.

egghead
egghead
~ 36 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today