Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a lot of documentation on Callbacks, VirtualPages and other topics #200

Merged
merged 9 commits into from
Jul 20, 2017

Conversation

romaninsh
Copy link
Member

Just a LOT of documentation

Copy link
Member

@DarkSide666 DarkSide666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good documentation. Now i understand callbacks and virtual page better.
Still there are few places where i would love to have just 1-2 sentences more with explanation what user will see on screen when trying examples provided above.

component.

One example of this behaviour is the format of :php:meth:`View::on` where you pass 2nd argument as a
PHP callback::

$button = new Buttion();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button

browser with a special GET argument a certain code can be triggered inside the on() method that short-circuts
output producing response specifically for button.
Adding Callback into any object will not affect the rendering, but it will make Callback part of the
:ref:`render_tree` and it will produce it with a unique callback URL:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't understand this part of sentence:
it will produce it with a unique callback URL

$label = $layout->add(['Label','Callback URL:']);
$cb = $label->add('Callback');
$label->detail = $cb->getURL();
$label->link($cb->getURL());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe one more sentence about what we will see on screen and what can we do with it.


.. php::class: Callback
if($cb->set(function(){ return true; })) {
$label->addClass('red');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more sentence about what will happen in this case.


.. php::method: getURL()
$cb->set(function(){ echo 123; });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above - 1 sentence about what will happen on screen


.. php:method: set(callback, arguments)
If you have passed argument to getURL() the value of this argument will be also asigned to $triggered property.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example?

$label = $layout->add(['Label','Callback URL:']);
$cb = $label->add('jsCallback');

$cb->set(function() use($app) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use($app) here

Although VirtualPage works without defining a callback, using one is more reliable and is always recommended::

$vp = $layout->add('VirtualPage');
$vp->set(function($vp){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 sentence about what we will see on screen and why

Copy link
Contributor

@ibelar ibelar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good in general.
As Imants say, it is difficult to understand, for a new atk user, what certain part of code is doing. Perhaps adding comment on code line, telling reader what this part of code does in final page rendering would help.
May be also adding a diagram, like sequence or flow diagram for example, would help better understand the concept of Callback.
But generally good documentation. It did help me a lot to understand Callback.

@romaninsh romaninsh merged commit 4c12c27 into develop Jul 20, 2017
@romaninsh romaninsh deleted the feature/add-callback-virtualpage-doc branch July 20, 2017 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants