Visibility

Access modifiers are special keywords which can be used to control the visibility and accessibility of component arguments.

Types of Access Modifiers

fastn provides two types of access modifiers which can be used with component arguments. If not specified, then the default visibility is public for all arguments defined under component definition. - `public` (Default): This ensures that the arguments can be accessed from anywhere. - `private`: This ensures that the argument can only be accessed from within the component.

How to use them ?

To use any access modifier, you simply need to specify it while defining component argument during component definition.
Using access modifier
-- component foo:
caption name:
private boolean mouse-hovered: false

-- ftd.text: $foo.name
color: red
color if { foo.mouse-hovered }: green
$on-mouse-enter$: $ftd.set-bool($a = $foo.mouse-hovered, v = true)
$on-mouse-leave$: $ftd.set-bool($a = $foo.mouse-hovered, v = false)

-- end: foo
Lang:
ftd
Here, we have defined a simple component `foo`. This component is using [`ftd.text`](ftd/text/), a kernel component, as a definition which displays the caption `name`. It has a private boolean argument `mouse-hovered` which can be only accessed from within the component itself. So while component invocation, we can't access this `mouse-hovered` argument.
Invalid component invocation
;; This should not be done
-- foo: xyz
$mouse-hovered: false
Lang:
ftd

Support `fastn`!

Enjoying `fastn`? Please consider giving us a star ⭐️ on [GitHub](https://github.com/fastn-stack/fastn) to show your support!
[⭐️](https://github.com/fastn-stack/fastn)

Getting Help

Have a question or need help? Visit our [GitHub Q&A discussion](https://github.com/fastn-stack/fastn/discussions/categories/q-a) to get answers and subscribe to it to stay tuned. Join our [Discord](https://discord.gg/a7eBUeutWD) channel and share your thoughts, suggestion, question etc. Connect with our [community](/community/)!
[💻️](/community/)

Found an issue?

If you find some issue, please visit our [GitHub issues](https://github.com/fastn-stack/fastn/issues) to tell us about it.

Quick links:

- [Install `fastn`](install/) - [Create `fastn` package](create-fastn-package/) - [Expander Crash Course](expander/) - [Syntax Highlighting in Sublime Text](/sublime/)

Join us

We welcome you to join our [Discord](https://discord.gg/a7eBUeutWD) community today. We are trying to create the language for human beings and we do not believe it would be possible without your support. We would love to hear from you.
Copyright © 2023 - [FifthTry.com](https://www.fifthtry.com/)