You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-18Lines changed: 17 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,22 @@ We originally developed it for ourselves to use in a video playing library at Ya
17
17
18
18
It's also possible you're the type of person who likes nerdy new software ideas. (Seriously though, who doesn't, amirite?) If that's the case, we guarantee you will find Behavior Graph interesting.
19
19
20
+
## Can I see an example?
21
+
22
+
Behavior Graph introduces a handful of new concepts.
23
+
These concepts aren't difficult, but you will require some orientation.
24
+
25
+
* We've created a [short walk-through of a Login form](https://yahoo.github.io/bgdocs/docs/jvm/code-example/) using Behavior Graph.
26
+
* You can also take a look at [one of our tutorials](https://yahoo.github.io/bgdocs/docs/jvm/tutorial-1/).
27
+
28
+
20
29
## How does it Work?
21
30
22
-
As programmers it's natural to partition our software into subtasks. For example, let's consider what happens on a typical login form.
31
+
As programmers, it's natural to partition our software into subtasks. For example, let's consider what happens on a typical login form.
23
32
24
33
1. When a user clicks on the Login button, we want to validate the Email and Password fields.
25
34
2. If validation passes, then we want to make a network call to log the user in.
26
-
3. Additionally we want to update the UI to provide feedback in case the validation fails, or disable the login button while we are actively logging in.
35
+
3. Additionally, we want to update the UI to provide feedback in case the validation fails, or disable the login button while we are actively logging in.
27
36
28
37
Most programming languages offer __functions__ as the primary tool for creating these subtasks. Conceptually we have three subtasks. So we will create three corresponding functions: `validateFields`, `networkLogin`, and `updateUI`. We will also need an additional `onLoginClick` function to run these tasks. It will look like this:
29
38
@@ -65,16 +74,6 @@ This gives us:
65
74
66
75
Behavior Graph isn't a replacement for functions. (We wrote it with functions, hello!) Instead it gives us higher level abstractions for partitioning our code into subtasks. It lets us say "these two blocks of code are related and here's how". And with that information the computer is able to run things for us. And humans are better able to infer the intent of the code.
67
76
68
-
## Can I see an example?
69
-
70
-
__We are updating our Kotlin documentation. Below are links to our Javascript/Typescript port which has a very similar API__
71
-
72
-
Behavior Graph introduces a handful of new concepts.
73
-
These concepts aren't difficult, but you will require some orientation.
74
-
75
-
* We've created a [short walk-through of a Login form](https://yahoo.github.io/bgdocs/docs/typescript/code-example/) using Behavior Graph.
76
-
* You can also take a look at [one of our tutorials](https://yahoo.github.io/bgdocs/docs/typescript/tutorials/tutorial-1/).
77
-
78
77
## Small
79
78
80
79
Behavior Graph is a small library. It's around 1500 lines of formatted code. It has no dependencies.
@@ -98,21 +97,21 @@ Behavior Graph has been ported to multiple platforms.
98
97
99
98
## Should I Use it in my Project?
100
99
101
-
This Kotlin version is not used in production at Yahoo currently. It is a direct port from the original Objective-C. It has excellent test coverage. We are confident it works as intended.
100
+
This Kotlin is minimally used at Yahoo currently. It is a direct port from the original Objective-C. It has excellent test coverage. We are confident it works as intended.
102
101
103
102
But it is also newly open sourced. You won't find blog posts and Stack Overflow answers to your questions. If you are on a team that expects that type of support you should proceed with caution.
104
103
105
104
## Obtaining Behavior Graph
106
105
107
-
Currently available only in source form on Github.
106
+
Behavior Graph is available in source form on [Github](https://github.com/yahoo/bgkotlin).
108
107
109
-
## Documentation
108
+
It is also available on Maven Central @ [com.yahoo.behaviorgraph/bgjvm](https://search.maven.org/artifact/com.yahoo.behaviorgraph/bgjvm).
110
109
111
-
__We are updating our Kotlin documentation. Below are links to our Javascript/Typescript port which has a very similar API__
110
+
## Documentation
112
111
113
-
[Go here for the full documentation site](https://yahoo.github.io/bgdocs/docs/typescript/).
112
+
[Go here for the full documentation site](https://yahoo.github.io/bgdocs/docs/).
114
113
115
-
While there are only a handful of basic concepts in Behavior Graph, it does require a shift in thinking. We recommend you start with the [Getting Started guide](https://yahoo.github.io/bgdocs/docs/typescript/quickstart/) then work through the [Tutorials](https://yahoo.github.io/bgdocs/docs/typescript/tutorials/tutorial-1/).
114
+
While there are only a handful of basic concepts in Behavior Graph, it does require a shift in thinking. We recommend you start with the [Getting Started guide](https://yahoo.github.io/bgdocs/docs/jvm/quickstart/) then work through the [Tutorials](https://yahoo.github.io/bgdocs/docs/jvm/tutorial-1/).
description ='Behavior Graph lets you build your programs out of small, easily understood pieces in a way that lets the computer do more of the work for you.'
Copy file name to clipboardExpand all lines: behavior-graph/src/main/kotlin/behaviorgraph/Behavior.kt
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
//
2
2
// Copyright Yahoo 2021
3
3
//
4
-
packagecom.yahoo.behaviorgraph
4
+
packagebehaviorgraph
5
5
6
6
/**
7
7
* A behavior is a block of code together with its dependency relationships (links). They are one of the two node types in a behavior graph. You define behaviors using the behavior() factory method of an Extent.
8
8
*
9
9
* Behaviors have both static and dynamic links. You provide static links when you create the behavior. Behavior Graph will update dynamic links per special methods on BehaviorBuilder or you can update them directly on a behavior.
10
10
* @property extent A behavior always has an [Extent] with which it is created.
* @param switches When these resources change, the `links` code block will run to determine which additional demands a behavior should depend on.
51
62
* @param relinkingOrder Should the dynamic demands be set before or after the behavior is run. If in doubt choose `RelinkingOrderPrior`
52
-
* @param links This anonymous function should return the additional set of demandsthe behavior will include. The `ext` parameter points to the [Extent] this behaivor is created on.
63
+
* @param links This anonymous function passes in an empty list of dynamic demands. You should add any additional demands the behavior will include. The `ctx` parameter points to the context object for the [Extent] this behaivor is created on.
* @param switches When these resources change, the `links` code block will run to determine which additional supplies a behavior should be responsible for.
71
101
* @param relinkingOrder Should the dynamic supplies be set before or after the behavior is run. If in doubt choose `RelinkingOrderPrior` (which is the default).
72
-
* @param links This anonymous function should return the additional set of suppliesthe behavior will include. The `ext` parameter points to the [Extent] this behaivor is created on.
102
+
* @param links This anonymous function passes in an empty list of dynamic supplies. You should add any additional supplies the behavior will include. The `ctx` parameter points to the context object for the [Extent] this behaivor is created on.
0 commit comments